classification
Title: sporadic test_sched failure
Type: behavior Stage: resolved
Components: Tests Versions: Python 3.4
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: serhiy.storchaka Nosy List: pitrou, python-dev, serhiy.storchaka
Priority: normal Keywords: patch

Created on 2013-01-02 21:14 by pitrou, last changed 2013-01-08 22:17 by serhiy.storchaka. This issue is now closed.

Files
File name Uploaded Description Edit
test_sched_concurrent.patch serhiy.storchaka, 2013-01-02 21:58 review
test_sched_deterministic_timer.patch serhiy.storchaka, 2013-01-03 21:16 Add a deterministic non-realtime timer review
test_sched_deterministic_timer_2.patch serhiy.storchaka, 2013-01-06 10:30 review
test_sched_queue.patch serhiy.storchaka, 2013-01-06 18:10 review
Messages (10)
msg178851 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2013-01-02 21:14
Just got this:

[255/372/1] test_sched
Warning -- threading._dangling was modified by test_sched
test test_sched failed -- Traceback (most recent call last):
  File "/home/antoine/cpython/default/Lib/test/test_sched.py", line 83, in test_cancel_concurrent
    scheduler.cancel(event1)
  File "/home/antoine/cpython/default/Lib/sched.py", line 96, in cancel
    self._queue.remove(event)
ValueError: list.remove(x): x not in list
msg178855 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2013-01-02 21:58
This is a test only issue.

There are two ways to fix this test. On first simple way we can just increase the timing and hope for a luck. On second more complicated way we should use custom deterministic time and sleep functions. Here is a first way patch to shut up the test failing.
msg178989 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2013-01-03 21:16
Here is a second way patch. It adds a deterministic non-realtime timer.
msg179088 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2013-01-04 22:19
+1 for the deterministic version.
msg179177 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2013-01-06 10:30
The previous patch is broken, here is a fixed, more complicated, patch. May be this class would be useful in other tests.
msg179178 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2013-01-06 12:12
> The previous patch is broken, here is a fixed, more complicated,
> patch. May be this class would be useful in other tests.

I don't understand what you're gaining with this complicated class: your
class guarantees that the sleepers will be woken up, but it doesn't
guarantee that any user code will actually run.

Perhaps the whole thing would be simpler if your tests used a Queue
instead of a list?
msg179199 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2013-01-06 18:10
> I don't understand what you're gaining with this complicated class: your
> class guarantees that the sleepers will be woken up, but it doesn't
> guarantee that any user code will actually run.

It guarantees that advance() returns only when all sleepers are sleeping or 
died, and all user code before specified time mark have executed. User code 
running does not take time, only sleeps take time. Actually this class is a 
forward-running time-machine with pause. But it looks overkill here.

> Perhaps the whole thing would be simpler if your tests used a Queue
> instead of a list?

Hmm, I had not occurred to this idea. Indeed, the patch is a little 
complicated (honestly speaking, it is a lot complicated). Here is a more 
simplified patch that uses a queue for synchronization in one direction and 
simple custom timer for synchronization in another direction. Thank you for 
suggestion.
msg179200 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2013-01-06 18:12
> Actually this class is a 
> forward-running time-machine with pause.

Perhaps you should give it to Guido as a present?
msg179203 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2013-01-06 18:36
> Perhaps you should give it to Guido as a present?

First I have to find some application for it. Wait for me at the 3013 year.
msg179380 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2013-01-08 22:16
New changeset ab36d3bb5996 by Serhiy Storchaka in branch '3.3':
Issue #16843: Make concurrent tests for sched module deterministic.
http://hg.python.org/cpython/rev/ab36d3bb5996

New changeset f65eae38f71e by Serhiy Storchaka in branch 'default':
Issue #16843: Make concurrent tests for sched module deterministic.
http://hg.python.org/cpython/rev/f65eae38f71e
History
Date User Action Args
2013-01-08 22:17:33serhiy.storchakasetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2013-01-08 22:16:07python-devsetnosy: + python-dev
messages: + msg179380
2013-01-06 18:36:06serhiy.storchakasetmessages: + msg179203
2013-01-06 18:12:46pitrousetmessages: + msg179200
2013-01-06 18:10:44serhiy.storchakasetfiles: + test_sched_queue.patch

messages: + msg179199
2013-01-06 12:12:16pitrousetmessages: + msg179178
2013-01-06 10:30:58serhiy.storchakasetfiles: + test_sched_deterministic_timer_2.patch

messages: + msg179177
2013-01-04 22:19:32pitrousetmessages: + msg179088
2013-01-03 21:24:24serhiy.storchakasetassignee: serhiy.storchaka
2013-01-03 21:16:02serhiy.storchakasetfiles: + test_sched_deterministic_timer.patch
assignee: serhiy.storchaka -> (no value)
messages: + msg178989

stage: patch review
2013-01-02 21:58:10serhiy.storchakasetfiles: + test_sched_concurrent.patch
messages: + msg178855

assignee: serhiy.storchaka
components: - Library (Lib)
keywords: + patch
2013-01-02 21:14:30pitroucreate