Skip to content

Commit cba9133

Browse files
committed
fix race condition
1 parent 16d5e7a commit cba9133

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

splitio/tasks/util/workerpool.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,15 +63,18 @@ def _wrapper(self, worker_number, func):
6363
while self._should_be_working[worker_number]:
6464
try:
6565
message = self._incoming.get(True, 0.5)
66-
self._incoming.task_done()
6766

6867
# For some reason message can be None in python2 implementation of queue.
6968
# This method must be both ignored and acknowledged with .task_done()
7069
# otherwise .join() will halt.
7170
if message is None:
71+
self._incoming.task_done()
7272
continue
7373

74+
# If the task is successfully executed, the ack is done AFTERWARDS,
75+
# to avoid race conditions on SDK initialization.
7476
ok = self._safe_run(func, message) #pylint: disable=invalid-name
77+
self._incoming.task_done()
7578
if not ok:
7679
self._logger.error(
7780
("Something went wrong during the execution, "

0 commit comments

Comments
 (0)