minrk / asyncio-atexit Goto Github PK
View Code? Open in Web Editor NEWatexit, but for asyncio
License: MIT License
atexit, but for asyncio
License: MIT License
Hi, I noticed this library seems to fail with uvloop
File "/my_file.py", line 71
asyncio_atexit.register(shutdown)
File "/my_path/lib/python3.9/site-packages/asyncio_atexit.py", line 48, in register
entry = _get_entry(loop)
File "/my_path/lib/python3.9/site-packages/asyncio_atexit.py", line 73, in _get_entry
_register_loop(loop)
File "/my_path/lib/python3.9/site-packages/asyncio_atexit.py", line 82, in _register_loop
_registry[loop] = _RegistryEntry(loop)
File "/my_path/lib/python3.9/site-packages/asyncio_atexit.py", line 25, in __init__
self._close_ref = weakref.WeakMethod(loop.close)
File "/my_path/lib/python3.9/weakref.py", line 52, in __new__
raise TypeError("argument should be a bound method, not {}"
TypeError: argument should be a bound method, not <class 'builtin_function_or_method'>
I recently added nest-asyncio
to a project that usesasyncio-atexit
and it seems to break it. Do you have any thoughts on how I could use both together?
# mre.py
import asyncio
import asyncio_atexit
async def finalizer():
print("running finalizer")
async def main():
asyncio_atexit.register(finalizer)
if __name__ == "__main__":
print("before")
asyncio.run(main())
print("after")
$ python mre.py
before
running finalizer
after
# mre.py
import asyncio
import asyncio_atexit
+ import nest_asyncio
+ nest_asyncio.apply()
async def finalizer():
print("running finalizer")
async def main():
asyncio_atexit.register(finalizer)
if __name__ == "__main__":
print("before")
asyncio.run(main())
print("after")
$ python mre.py
before
after
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.