This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author ncoghlan
Recipients brett.cannon, ncoghlan, pitrou
Date 2010-08-22.09:16:13
SpamBayes Score 3.35386e-06
Marked as misclassified No
Message-id <>
It would be good if the test timed out rather than deadlocking in the face of a broken import lock.

I suggest:
1. Make the two test threads daemon threads
2. Specify a timeout to the join() calls
3. Use self.assertFalse(t1.is_alive()) and self.assertFalse(t2.is_alive()) to check the calls actually finished

For your #9260 testing, this looks like it may be a little probabilistic. I think you can make the deadlock a near certainty by defining your test modules and threads as follows:

# Create a circular import structure: A -> C -> B -> D -> A
circular_imports_modules = {
    'A': """if 1:
        import ev
        import time
        x = 'a'
        import C
    'B': """if 1:
        import ev
        import time
        x = 'b'
        import D
    'C': """import B""",
    'D': """import A""",
    'ev': """if 1:
         import threading;
         evA = threading.Event()
         evB = threading.Event()

        def import_ab():
            import ev
            import A
            results.append(getattr(A, 'x', None))
        def import_ba():
            import ev
            import B
            results.append(getattr(B, 'x', None))

(I've done a trick along these lines before, and the above doesn't look quite right. Maybe the details will come back to me if I sit on it for a while)
Date User Action Args
2010-08-22 09:16:16ncoghlansetrecipients: + ncoghlan, brett.cannon, pitrou
2010-08-22 09:16:16ncoghlansetmessageid: <>
2010-08-22 09:16:14ncoghlanlinkissue9657 messages
2010-08-22 09:16:13ncoghlancreate