Skip to content
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

Closed
pitrou opened this issue Apr 6, 2011 · 6 comments
Closed

transient failure in test_multiprocessing.WithProcessesTestCondition #55999

pitrou opened this issue Apr 6, 2011 · 6 comments
Labels
stdlib Python modules in the Lib dir tests Tests in the Lib/test dir type-bug An unexpected behavior, bug, or error

Comments

@pitrou
Copy link
Member

pitrou commented Apr 6, 2011

BPO 11790
Nosy @pitrou, @vstinner
PRs
  • [2.7] bpo-11790: Fix sporadic failures in test_multiprocessing.WithProcessesTestCondition #1591
  • 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:

    assignee = None
    closed_at = <Date 2011-04-16.19:03:59.103>
    created_at = <Date 2011-04-06.23:04:34.959>
    labels = ['tests', 'type-bug', 'library']
    title = 'transient failure in test_multiprocessing.WithProcessesTestCondition'
    updated_at = <Date 2017-05-15.15:32:16.774>
    user = 'https://github.com/pitrou'

    bugs.python.org fields:

    activity = <Date 2017-05-15.15:32:16.774>
    actor = 'vstinner'
    assignee = 'none'
    closed = True
    closed_date = <Date 2011-04-16.19:03:59.103>
    closer = 'pitrou'
    components = ['Library (Lib)', 'Tests']
    creation = <Date 2011-04-06.23:04:34.959>
    creator = 'pitrou'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 11790
    keywords = []
    message_count = 6.0
    messages = ['133182', '133533', '133536', '133901', '133902', '293714']
    nosy_count = 4.0
    nosy_names = ['pitrou', 'vstinner', 'neologix', 'python-dev']
    pr_nums = ['1591']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue11790'
    versions = ['Python 3.2', 'Python 3.3']

    @pitrou
    Copy link
    Member Author

    pitrou commented Apr 6, 2011

    http://www.python.org/dev/buildbot/all/builders/x86%20FreeBSD%207.2%202.7/builds/519/steps/test/logs/stdio

    ======================================================================
    FAIL: test_notify_all (test.test_multiprocessing.WithProcessesTestCondition)
    ----------------------------------------------------------------------

    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

    @pitrou pitrou added stdlib Python modules in the Lib dir tests Tests in the Lib/test dir type-bug An unexpected behavior, bug, or error labels Apr 6, 2011
    @neologix
    Copy link
    Mannequin

    neologix mannequin commented Apr 11, 2011

    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
    764 self.assertReturnsIfImplemented(0, get_value, woken)
    with woken.get_value() == 5

    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
    763 time.sleep(10 * DELTA)

    @neologix
    Copy link
    Mannequin

    neologix mannequin commented Apr 11, 2011

    Sorry, wrong copy-paste, the failing assertion will of course be this one:
    773 self.assertReturnsIfImplemented(6, get_value, woken)

    since woken.get_value() == 5

    @pitrou
    Copy link
    Member Author

    pitrou commented Apr 16, 2011

    Indeed, it just seems that the sleep period is sometimes too low. Will commit a patch.

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Apr 16, 2011

    New changeset 88f1907fe312 by Antoine Pitrou in branch '3.2':
    Issue bpo-11790: Fix sporadic failures in test_multiprocessing.WithProcessesTestCondition.
    http://hg.python.org/cpython/rev/88f1907fe312

    New changeset 0ecfa2ce6561 by Antoine Pitrou in branch 'default':
    Issue bpo-11790: Fix sporadic failures in test_multiprocessing.WithProcessesTestCondition.
    http://hg.python.org/cpython/rev/0ecfa2ce6561

    @pitrou pitrou closed this as completed Apr 16, 2011
    @vstinner
    Copy link
    Member

    New changeset 9d1983b by Victor Stinner in branch '2.7':
    bpo-11790: Fix sporadic failures in test_multiprocessing.WithProcessesTestCondition. (bpo-1591)
    9d1983b

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    stdlib Python modules in the Lib dir tests Tests in the Lib/test dir type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants