Ensure the worker threads have updates once they acquire the lock

This commit is contained in:
Lonami Exo 2017-09-30 10:59:33 +02:00
parent 9560bcc324
commit 72b7e99222

View File

@ -1,4 +1,5 @@
import logging import logging
import threading
from collections import deque from collections import deque
from datetime import datetime from datetime import datetime
from threading import RLock, Event, Thread from threading import RLock, Event, Thread
@ -41,6 +42,9 @@ class UpdateState:
self._updates_available.wait() self._updates_available.wait()
with self._updates_lock: with self._updates_lock:
if not self._updates_available.is_set():
return
update = self._updates.popleft() update = self._updates.popleft()
if not self._updates: if not self._updates:
self._updates_available.clear() self._updates_available.clear()