diff options
author | shailshouryya <42100758+shailshouryya@users.noreply.github.com> | 2023-07-25 17:27:36 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-07-25 17:27:36 (GMT) |
commit | fabcbe9c12688eb9a902a5c89cb720ed373625c5 (patch) | |
tree | 03b8fa5c5bf1ec7cfc538e2a442e5610438e2955 /Lib/multiprocessing/resource_tracker.py | |
parent | 188000ae4b486cfffaeaa0a06902e4844d1b2bbc (diff) | |
download | cpython-fabcbe9c12688eb9a902a5c89cb720ed373625c5.zip cpython-fabcbe9c12688eb9a902a5c89cb720ed373625c5.tar.gz cpython-fabcbe9c12688eb9a902a5c89cb720ed373625c5.tar.bz2 |
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>
Diffstat (limited to 'Lib/multiprocessing/resource_tracker.py')
-rw-r--r-- | Lib/multiprocessing/resource_tracker.py | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/Lib/multiprocessing/resource_tracker.py b/Lib/multiprocessing/resource_tracker.py index ea36950..3783c1f 100644 --- a/Lib/multiprocessing/resource_tracker.py +++ b/Lib/multiprocessing/resource_tracker.py @@ -221,9 +221,10 @@ def main(fd): 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)) + warnings.warn( + f'resource_tracker: There appear to be {len(rtype_cache)} ' + f'leaked {rtype} objects to clean up at shutdown: {rtype_cache}' + ) except Exception: pass for name in rtype_cache: |