File tree 2 files changed +13
-1
lines changed
2 files changed +13
-1
lines changed Original file line number Diff line number Diff line change 7
7
8
8
from artiq .protocols import pyon
9
9
from artiq .language .units import strip_unit
10
- from artiq .tools import asyncio_process_wait_timeout , asyncio_wait_or_cancel
10
+ from artiq .tools import (asyncio_process_wait_timeout , asyncio_process_wait ,
11
+ asyncio_wait_or_cancel )
11
12
12
13
13
14
logger = logging .getLogger (__name__ )
@@ -101,13 +102,15 @@ def close(self):
101
102
logger .warning ("failed to send terminate command to worker"
102
103
" (RID %d), killing" , self .rid , exc_info = True )
103
104
self .process .kill ()
105
+ yield from asyncio_process_wait (self .process )
104
106
return
105
107
try :
106
108
yield from asyncio_process_wait_timeout (self .process ,
107
109
self .term_timeout )
108
110
except asyncio .TimeoutError :
109
111
logger .warning ("worker did not exit (RID %d), killing" , self .rid )
110
112
self .process .kill ()
113
+ yield from asyncio_process_wait (self .process )
111
114
else :
112
115
logger .debug ("worker exited gracefully (RID %d)" , self .rid )
113
116
finally :
Original file line number Diff line number Diff line change @@ -18,6 +18,7 @@ def parse_arguments(arguments):
18
18
d [name ] = pyon .decode (value )
19
19
return d
20
20
21
+
21
22
def format_arguments (arguments ):
22
23
fmtargs = []
23
24
for k , v in sorted (arguments .items (), key = itemgetter (0 )):
@@ -98,6 +99,14 @@ def asyncio_process_wait_timeout(process, timeout):
98
99
timeout = end_time - time .monotonic ())
99
100
100
101
102
+ @asyncio .coroutine
103
+ def asyncio_process_wait (process ):
104
+ r = True
105
+ while r :
106
+ f , p = yield from asyncio .wait ([process .stdout .read (1024 )])
107
+ r = f .pop ().result ()
108
+
109
+
101
110
@asyncio .coroutine
102
111
def asyncio_wait_or_cancel (fs , ** kwargs ):
103
112
fs = [asyncio .async (f ) for f in fs ]
You can’t perform that action at this time.
0 commit comments