Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
allgo
allgo
Commits
f952aaf0
Commit
f952aaf0
authored
Feb 02, 2017
by
BAIRE Anthony
Browse files
in the watcher: use the loop stored in the future
(this was breaking the tests)
parent
7c90e010
Changes
1
Hide whitespace changes
Inline
Side-by-side
docker/controller.py
View file @
f952aaf0
...
...
@@ -799,8 +799,6 @@ class DockerWatcher:
# {container_id: future}
self
.
_futures
=
{}
self
.
_loop
=
asyncio
.
get_event_loop
()
self
.
_shutdown
=
False
self
.
_thread
=
threading
.
Thread
(
target
=
self
.
_thread_func
)
...
...
@@ -816,22 +814,22 @@ class DockerWatcher:
while
not
self
.
_shutdown
:
# pragma: nobranch
next
(
limiter
)
try
:
for
event
in
self
.
_client
.
events
(
filters
=
{
"event"
:
"die"
}):
for
event
_bytes
in
self
.
_client
.
events
(
filters
=
{
"event"
:
"die"
}):
if
self
.
_shutdown
:
return
log
.
debug
(
"docker event %r"
,
event
)
self
.
_loop
.
call_soon_threadsafe
(
self
.
_event
,
event
)
log
.
debug
(
"docker event %r"
,
event_bytes
)
event
=
json
.
loads
(
event_bytes
.
decode
())
if
event
[
"status"
]
==
"die"
:
cid
=
event
[
"id"
]
fut
=
self
.
_futures
.
get
(
cid
)
if
fut
is
not
None
and
not
fut
.
done
():
fut
.
_loop
.
call_soon_threadsafe
(
fut
.
set_result
,
None
)
except
Exception
:
log
.
exception
(
"docker watcher exception"
)
def
_event
(
self
,
event_bytes
):
event
=
json
.
loads
(
event_bytes
.
decode
())
if
event
[
"status"
]
==
"die"
:
cid
=
event
[
"id"
]
fut
=
self
.
_futures
.
get
(
cid
)
if
fut
is
not
None
and
not
fut
.
done
():
fut
.
set_result
(
None
)
def
shutdown
(
self
):
"""Shutdown the watcher
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment