You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
event_loop_modules of Pyjo.Reactor, so that finalizers defer their cleanups below the frames of the event loop #7
Pyjo.Reactor._finalize defers the cleanup of a finalizer that the garbage collector runs in the middle of the code of a reactor or of its event loop, so that closing a stream or removing an acceptor does not change the structures that the reactor or the event loop are changing. Since pyjoyment/Pyjoyment#534 (pyjoyment/Pyjoyment#533), it finds those frames:
in the files of the modules of the classes of the reactors, wherever they are installed, also editable, as in development and in the workflow Tests, where Pyjo/Reactor/Uvloop.py of this repository is not next to the reactors of Pyjoyment;
in the loaded modules that the new class attribute event_loop_modules names, a package as its directory, a module as its file.
Pyjo.Reactor.Asyncio names ('asyncio', 'selectors') there, which _prefixes() had hard-coded before.
What to do here
Pyjo_Reactor_Uvloop inherits ('asyncio', 'selectors') from Pyjo.Reactor.Asyncio, and Pyjo/Reactor/Uvloop.py, with _Loop, is covered as the module of the class. The loop of uvloop is compiled with Cython and has no frames of Python, so there may be nothing to name: check whether a callback of the reactor runs below a frame of the Python modules of uvloop, and if it does, extend the attribute, as event_loop_modules = (*Pyjo.Reactor.Asyncio.object.event_loop_modules, 'uvloop').
Test it with the suite of Pyjoyment on this reactor with PYTHONDEVMODE=1, t/stdlib/IOLoop_gc.py above all, and with PyPy, whose garbage collector runs anywhere.
Checked, nothing to name: event_loop_modules stays the inherited ('asyncio', 'selectors'), with Pyjo/Reactor/Uvloop.py and its _Loop covered as the module of the class.
A probe of Pyjo.Reactor._finalize (through sitecustomize) recorded the stack of every call over the whole suite of Pyjoyment b6d623e on the reactor with PYTHONDEVMODE=1: 4265 calls in 198 processes, t/stdlib/IOLoop_gc.py among them, and no frame of the directory of uvloop nor of a .pyx below any of them. The loop of uvloop is compiled with Cython and makes no frames of Python.
The one place with frames of uvloop/__init__.py is the code that uvloop.run runs, its run and wrapper, and below them is asyncio/runners.py, which asyncio covers already, so 'uvloop' would change nothing.
Activity
Pyjo.Reactor.Uvloop: a timer not due before its time, and event_loop_…
dex4er commentedon Nov 5, 2026
Checked, nothing to name:
event_loop_modulesstays the inherited('asyncio', 'selectors'), withPyjo/Reactor/Uvloop.pyand its_Loopcovered as the module of the class.Pyjo.Reactor._finalize(throughsitecustomize) recorded the stack of every call over the whole suite of Pyjoyment b6d623e on the reactor withPYTHONDEVMODE=1: 4265 calls in 198 processes,t/stdlib/IOLoop_gc.pyamong them, and no frame of the directory of uvloop nor of a.pyxbelow any of them. The loop of uvloop is compiled with Cython and makes no frames of Python.uvloop/__init__.pyis the code thatuvloop.runruns, itsrunandwrapper, and below them isasyncio/runners.py, whichasynciocovers already, so'uvloop'would change nothing.uv.locktakes Pyjoyment b6d623e with pyjoyment/Pyjoyment#534, andAGENTS.mdnotes the above, in #8.