Bug 8257 - ResourceWarning messages aren't properly logged
Summary: ResourceWarning messages aren't properly logged
Status: NEW
Alias: None
Product: ThinLinc
Classification: Unclassified
Component: Other (show other bugs)
Version: trunk
Hardware: PC Unknown
: P2 Normal
Target Milestone: LowPrio
Assignee: Bugzilla mail exporter
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-11-22 09:56 CET by Pierre Ossman
Modified: 2023-12-05 13:06 CET (History)
1 user (show)

See Also:
Acceptance Criteria:


Attachments

Description Pierre Ossman cendio 2023-11-22 09:56:23 CET
When running development builds, Python can complain with a ResourceWarning if some things are not explicitly cleaned up:

> sys:1: ResourceWarning: unclosed <socket.socket fd=7, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=6, laddr=('10.48.2.210', 1022), raddr=('10.48.2.210', 904)>
> ResourceWarning: Enable tracemalloc to get the object allocation traceback
> /usr/lib64/python3.9/asyncio/selector_events.py:702: ResourceWarning: unclosed transport <_SelectorSocketTransport fd=7>
>   _warn(f"unclosed transport {self!r}", ResourceWarning, source=self)
> ResourceWarning: Enable tracemalloc to get the object allocation traceback

However, as seen above, it doesn't follow the proper log format. It also likely doesn't follow any of the other log settings either.
Comment 1 Adam Halim cendio 2023-11-23 10:21:18 CET
(In reply to Pierre Ossman from comment #0)
> When running development builds, Python can complain with a ResourceWarning
> if some things are not explicitly cleaned up:
I get the same warnings even when running a non developer build. It looks like asyncio warnings are displayed no matter what build you're running, while some asyncio logging gets filtered when not running a developer build.
Comment 2 Adam Halim cendio 2023-11-30 09:42:03 CET
(In reply to Adam Halim from comment #1)
> (In reply to Pierre Ossman from comment #0)
> > When running development builds, Python can complain with a ResourceWarning
> > if some things are not explicitly cleaned up:
> I get the same warnings even when running a non developer build. It looks
> like asyncio warnings are displayed no matter what build you're running,
> while some asyncio logging gets filtered when not running a developer build.
In comment #1, I only commented out export PYTHONDEVMODE=1 in /opt/thinlinc/libexec/python3 which filtered out some logging done by the logging module. Logging done by the warning mode was unaffected, and after commenting out export PYTHONWARNINGS=default, ResourceWarning were no longer logged.

https://docs.python.org/3/library/warnings.html#default-warning-filter

Note You need to log in before you can comment on or make changes to this bug.