New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
transient failure in test_multiprocessing.WithProcessesTestCondition #55999
Comments
====================================================================== Traceback (most recent call last):
File "/usr/home/db3l/buildarea/2.7.bolen-freebsd7/build/Lib/test/test_multiprocessing.py", line 757, in test_notify_all
self.assertReturnsIfImplemented(6, get_value, woken)
File "/usr/home/db3l/buildarea/2.7.bolen-freebsd7/build/Lib/test/test_multiprocessing.py", line 116, in assertReturnsIfImplemented
return self.assertEqual(value, res)
AssertionError: 6 != 5 |
One possible cause for those intermittent failures is the preemtion of a thread while waiting on the condition: def wait(self, timeout=None):
233 assert self._lock._semlock._is_mine(), \
234 'must acquire() condition before using wait()'
235
236 # indicate that this thread is going to sleep
237 self._sleeping_count.release()
238
239 # release lock
240 count = self._lock._semlock._count()
241 for i in range(count):
242 self._lock.release()
243
<-- here
244 try:
245 # wait for notification or timeout
246 ret = self._wait_semaphore.acquire(True, timeout) For example, if the last thread/process is preempted after having released the condition's lock (and hence performed a up on the "sleeping" semaphore sooner in the "f" function) but before waiting on the condition's semaphore, since the main thread only waits 0.1s before locking the condition and performing a notify_all on it (it will proceed since all the threads performed an up on "sleeping"), only the threads already waiting on the condition will be woken up, this last thread won't be woken up, triggering a failure in this assertion It's just a guess, but I'd suggest increasing the sleep before trying to signal the condition a bit: 762 # check no process/thread has woken up |
Sorry, wrong copy-paste, the failing assertion will of course be this one: since woken.get_value() == 5 |
Indeed, it just seems that the sleep period is sometimes too low. Will commit a patch. |
New changeset 88f1907fe312 by Antoine Pitrou in branch '3.2': New changeset 0ecfa2ce6561 by Antoine Pitrou in branch 'default': |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: