Opened 11 years ago

Closed 6 years ago

#2498 defect closed fixed (fixed)

trial hangs with threadpool

Reported by: jack Owned by: jack
Priority: normal Milestone:
Component: trial Keywords: threadpool
Cc: jack, twonds, jesstess Branch:
Author:

Description

The attached test causes trial to hang reliably on at least Mac OS X. It appears that reactor isn't sending the shutdown event.

Attachments (1)

test_trialbug.py (579 bytes) - added by jack 11 years ago.
testcase that causes trial to hang

Download all attachments as: .zip

Change History (7)

Changed 11 years ago by jack

Attachment: test_trialbug.py added

testcase that causes trial to hang

comment:1 Changed 11 years ago by jack

Cc: jack twonds added

comment:2 Changed 11 years ago by jack

It turns out adbapi has special case code probably written for this. The issue is that when setUp() is called, the systemEventTrigger for callWhenRunning has already fired. so _start() is not called. After tearDown() the systemEventTrigger for 'shutdown' is called, and then trial fires off the callWhenRunning triggers a second time. This actually causes our _start() to get called (after the test case is finished) and trial doesn't ever seem to fire of the final 'shutdown' trigger.

It seems to me that for this to work like one expects, callWhenRunning triggers should be fired after setUp(), and perhaps 'shutdown' triggers should be fired before tearDown for symmetry.

A workaround is to call _start() in setUp() and shutdown the threadpool in tearDown() and additionally be sure to removeSystemEventTrigger for the callWhenRunning event so that _start() does not get called a second time after our test case is finished.

Note that the fact that the attached test fails in setUp() is irrelevant to the hang. It hangs if there is no failure as well.

comment:3 Changed 7 years ago by <automation>

Owner: Jonathan Lange deleted

comment:4 Changed 6 years ago by jesstess

Cc: jesstess added
Owner: set to jack

Belatedly, thanks for reporting this jack. With Twisted 11.0 on OS X 10.6 your test does not hang for me. Can you confirm that this is still an issue for you with a newer version of Twisted?

comment:5 Changed 6 years ago by jack

I can also confirm that it does not hang under OS X 10.7.2 and Twisted 11.0.

However, 5 years later, I cannot remember many details (like whether it hung 100% of the time or was more sporadic). I suspect it was a 100% hang issue.

I think it's safe to close this as WFM or if you know that code has been changed, fixed.

comment:6 Changed 6 years ago by jesstess

Resolution: fixed
Status: newclosed

Thanks for checking in, jack. I'll go ahead and close it.

Note: See TracTickets for help on using tickets.