Issue 7222: thread reaping is imperfect (original) (raw)

Created on 2009-10-27 21:24 by pitrou, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
threading_setup.patch pitrou,2009-10-27 21:24
threading_setup2.patch pitrou,2009-10-27 23:41
Messages (5)
msg94582 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2009-10-27 21:24
Thread reaping in test_support is imperfect because, even when a thread has a disappeared from _active and _limbo, the Thread object might still be hanging somewhere in memory (leaving its last instants). This problem manifests itself when trying to fix the transient refleaks in test_socketserver. One solution I've found is to add a _count() method to the thread module, which returns the number of running threads from the point of view of the C extension. When _count() is decremented, we can be sure the Python method has finished running and the Thread object is not hanging around.
msg94584 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2009-10-27 22:14
Thinking about it, another possibility is to strengthen Thread.join(), so that it waits for the actual end of the thread, not a small instant before.
msg94586 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2009-10-27 23:25
Forget the last message. While improving Thread.join() can be good, it still doesn't guarantee that all references have been released.
msg94592 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2009-10-27 23:41
Here's a new patch with tests.
msg94716 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2009-10-30 17:25
Committed in r75958, r75959.
History
Date User Action Args
2022-04-11 14:56:54 admin set github: 51471
2009-10-30 17:25:52 pitrou set status: open -> closedresolution: fixedmessages: + stage: patch review -> resolved
2009-10-27 23:41:21 pitrou set files: + threading_setup2.patchmessages: +
2009-10-27 23:25:07 pitrou set messages: +
2009-10-27 22:14:14 pitrou set messages: +
2009-10-27 21:24:22 pitrou create