File tree 1 file changed +6
-3
lines changed
1 file changed +6
-3
lines changed Original file line number Diff line number Diff line change 6
6
class Scheduler :
7
7
def __init__ (self , * args , ** kwargs ):
8
8
self .worker = Worker (* args , ** kwargs )
9
- self .queue = asyncio .Queue ()
9
+ self .queued = []
10
+ self .queue_count = asyncio .Semaphore (0 )
10
11
11
12
@asyncio .coroutine
12
13
def start (self ):
@@ -21,11 +22,13 @@ def stop(self):
21
22
yield from self .worker .end_process ()
22
23
23
24
def run_once (self , run_params , timeout ):
24
- self .queue .put_nowait ((run_params , timeout ))
25
+ self .queued .append ((run_params , timeout ))
26
+ self .queue_count .release ()
25
27
26
28
@asyncio .coroutine
27
29
def _schedule (self ):
28
30
while True :
29
- run_params , timeout = yield from self .queue .get ()
31
+ yield from self .queue_count .acquire ()
32
+ run_params , timeout = self .queued .pop (0 )
30
33
result = yield from self .worker .run (run_params , timeout )
31
34
print (result )
You can’t perform that action at this time.
0 commit comments