Skip to content

Commit 08f2aa8

Browse files
committedDec 9, 2014
management/scheduler: replace queue with transparent list + semaphore
1 parent 059608d commit 08f2aa8

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed
 

‎artiq/management/scheduler.py

+6-3
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
class Scheduler:
77
def __init__(self, *args, **kwargs):
88
self.worker = Worker(*args, **kwargs)
9-
self.queue = asyncio.Queue()
9+
self.queued = []
10+
self.queue_count = asyncio.Semaphore(0)
1011

1112
@asyncio.coroutine
1213
def start(self):
@@ -21,11 +22,13 @@ def stop(self):
2122
yield from self.worker.end_process()
2223

2324
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()
2527

2628
@asyncio.coroutine
2729
def _schedule(self):
2830
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)
3033
result = yield from self.worker.run(run_params, timeout)
3134
print(result)

0 commit comments

Comments
 (0)
Please sign in to comment.