Use events instead of sleep for result reading
This commit is contained in:
parent
f860ea10c4
commit
9b6b924e9c
2 changed files with 5 additions and 1 deletions
|
@ -129,6 +129,7 @@ class TaskQueueManager:
|
|||
|
||||
self._res_queue = deque()
|
||||
self._res_queue_lock = threading.Lock()
|
||||
self._res_ready = threading.Event()
|
||||
|
||||
def _put_in_queue(self, data, queue, lock):
|
||||
lock.acquire()
|
||||
|
@ -154,6 +155,7 @@ class TaskQueueManager:
|
|||
|
||||
def put_result(self, data):
|
||||
self._put_in_queue(data, self._res_queue, self._res_queue_lock)
|
||||
self._res_ready.set()
|
||||
|
||||
def get_result(self):
|
||||
return self._pop_off_queue(self._res_queue, self._res_queue_lock)
|
||||
|
|
|
@ -506,7 +506,9 @@ class StrategyBase:
|
|||
results = self._process_pending_results(iterator)
|
||||
ret_results.extend(results)
|
||||
if self._pending_results > 0:
|
||||
time.sleep(C.DEFAULT_INTERNAL_POLL_INTERVAL)
|
||||
#time.sleep(C.DEFAULT_INTERNAL_POLL_INTERVAL)
|
||||
self._tqm._res_ready.wait()
|
||||
self._tqm._res_ready.clear()
|
||||
|
||||
display.debug("no more pending results, returning what we have")
|
||||
|
||||
|
|
Loading…
Reference in a new issue