Skip to content

Commit fabcbe9

Browse files
gh-106739: Add rtype_cache to warnings.warn message when leaked objects found (#106740)
Adding the `rtype_cache` to the `warnings.warn` message improves the previous, somewhat vague message from ``` /Users/username/cpython/Lib/multiprocessing/resource_tracker.py:224: UserWarning: resource_tracker: There appear to be 6 leaked semaphore objects to clean up at shutdown ``` to ``` /Users/username/cpython/Lib/multiprocessing/resource_tracker.py:224: UserWarning: resource_tracker: There appear to be 6 leaked semaphore objects to clean up at shutdown: {'/mp-yor5cvj8', '/mp-10jx8eqr', '/mp-eobsx9tt', '/mp-0lml23vl', '/mp-9dgtsa_m', '/mp-frntyv4s'} ``` --------- Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
1 parent 188000a commit fabcbe9

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

Lib/multiprocessing/resource_tracker.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -221,9 +221,10 @@ def main(fd):
221221
for rtype, rtype_cache in cache.items():
222222
if rtype_cache:
223223
try:
224-
warnings.warn('resource_tracker: There appear to be %d '
225-
'leaked %s objects to clean up at shutdown' %
226-
(len(rtype_cache), rtype))
224+
warnings.warn(
225+
f'resource_tracker: There appear to be {len(rtype_cache)} '
226+
f'leaked {rtype} objects to clean up at shutdown: {rtype_cache}'
227+
)
227228
except Exception:
228229
pass
229230
for name in rtype_cache:
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Add the ``rtype_cache`` to the warning message (as an addition to the type of leaked objects and the number of leaked objects already included in the message) to make debugging leaked objects easier when the multiprocessing resource tracker process finds leaked objects at shutdown. This helps more quickly identify what was leaked and/or why the leaked object was not properly cleaned up.

0 commit comments

Comments
 (0)