Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork33.7k
Description
Feature or enhancement
Add thertype_cache (which is aset that includes all leaked objects of a particular type) to thewarnings.warn message inLib/multiprocessing/resource_tracker.py when any leaked objects are found to make debugging easier:
cpython/Lib/multiprocessing/resource_tracker.py
Lines 224 to 226 in490295d
| warnings.warn('resource_tracker: There appear to be %d ' | |
| 'leaked %s objects to clean up at shutdown'% | |
| (len(rtype_cache),rtype)) |
Pitch
When theresource_tracker module (Lib/multiprocessing/resource_tracker.py) finds leaked objects, thefinally block in themain function includes the type of leaked objects and the number of leaked objects, but does not actually include the objects that are leaked. Adding theset ofrtype_cache to thewarnings.warn message will make debugging much more useful, as the names of the leaked objects could help more quickly identify what was leaked and/or why the leaked object was not properly cleaned up.
The permalink attached above links directly to the relevant code as it is currently implemented, but I'm adding it again below with some surrounding code for reference here:
finally: # all processes have terminated; cleanup any remaining resources for rtype, rtype_cache in cache.items(): if rtype_cache: try: warnings.warn('resource_tracker: There appear to be %d ' 'leaked %s objects to clean up at shutdown' % (len(rtype_cache), rtype)) except Exception: passPrevious discussion
A recent example of an issue where the additional context would have been useful is#104090, in which the current warning message is/workspace/cpython/Lib/multiprocessing/resource_tracker.py:224: UserWarning: resource_tracker: There appear to be 6 leaked semaphore objects to clean up at shutdown.