databento/live/client.py defines Live._loop = asyncio.new_event_loop()
as a class-body attribute (line 78 in v0.78.0), executed at class-definition
time — i.e. at import time of databento.live.client, not when Live is
instantiated. The backing thread is only started lazily in __init__
(Live._thread.start(), gated by is_alive()), so the loop created at
import time is never run and never explicitly closed if Live is never
instantiated.
At interpreter shutdown, Python's GC finalizes the unused loop and emits:
ResourceWarning: unclosed event loop <_UnixSelectorEventLoop running=False closed=False debug=False>
Repro — this warning fires from only importing the package, no Live
usage at all:
$ python3 -W always -c "import databento"
... (warning appears at process exit)
This is distinct from #99 (which asked about injecting an existing loop
for async integration) — here the problem is that merely importing
databento allocates OS-level resources (an event loop) that are never
used or released if the caller's code path never touches Live at all
(e.g. only uses the historical/batch APIs or enum/schema constants).
Suggested fix: defer loop creation to Live.__init__ (or a lazy
classmethod/property) instead of the class body, so importing the module
has no side effects.
Environment: databento-python 0.78.0, Python 3.14.4, macOS arm64.
databento/live/client.pydefinesLive._loop = asyncio.new_event_loop()as a class-body attribute (line 78 in v0.78.0), executed at class-definition
time — i.e. at import time of
databento.live.client, not whenLiveisinstantiated. The backing thread is only started lazily in
__init__(
Live._thread.start(), gated byis_alive()), so the loop created atimport time is never run and never explicitly closed if
Liveis neverinstantiated.
At interpreter shutdown, Python's GC finalizes the unused loop and emits:
Repro — this warning fires from only importing the package, no
Liveusage at all:
This is distinct from #99 (which asked about injecting an existing loop
for async integration) — here the problem is that merely importing
databentoallocates OS-level resources (an event loop) that are neverused or released if the caller's code path never touches
Liveat all(e.g. only uses the historical/batch APIs or enum/schema constants).
Suggested fix: defer loop creation to
Live.__init__(or a lazyclassmethod/property) instead of the class body, so importing the module
has no side effects.
Environment: databento-python 0.78.0, Python 3.14.4, macOS arm64.