gh-106739: Add rtype_cache to warnings.warn message when leaked objects found#106740
Conversation
|
Most changes to Python require a NEWS entry. Please add it using the blurb_it web app or the blurb command-line tool. |
rtype_cache to warnings.warn message when leaked objects foundrtype_cache to warnings.warn message when leaked objects found
|
|
|
@iritkatriel tagging you here since I saw you were also involved in #104090 and the pull requests associated with that issue. Let me know what you think of this when you get the chance! 🤓 (Or let me know if I should tag someone else instead) |
|
CC @pitrou . |
Misc/NEWS.d/next/Library/2023-07-20-06-00-35.gh-issue-106739.W1hygr.rst
Outdated
Show resolved
Hide resolved
|
@shailshouryya Can you show an example of the improved warning message? |
Sure! Prior to these changes, the warning message looked like
and after these changes, the warning message looks like
I got these outputs by running Full command to rebuild and test (on macOS)GDBM_CFLAGS="-I$(dirname $(dirname $(which port)))/include" \ GDBM_LIBS="-L$(dirname $(dirname $(which port)))/lib -lgdbm" \ ./configure --with-pydebug && make regen-global-objects && make -s -j3 \ && ./python.exe -m test test_concurrent_futures --verbose |
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'}
```
The previously used f-string format did not properly interpolate the
variables, and resulted in an output such as the following:
```
/Users/username/cpython/Lib/multiprocessing/resource_tracker.py:224: UserWarning: resource_tracker: There appear to be 6 leaked {rtype} objects to clean up at shutdown: {rtype_cache}
```
Resource: https://stackoverflow.com/questions/49416042/how-to-write-an-f-string-on-multiple-lines-without-introducing-unintended-whites
1611dd4 to
17f4769
Compare
…aked objects found (python#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>
Closes Issue #106739: Add rtype_cache to warnings.warn message when leaked objects found
See message in commit a54a5fb for the updated warning message.
rtype_cachetowarnings.warnmessage when leaked objects found #106739