Coder Social home page Coder Social logo

asyncio-atexit's People

Contributors

minrk avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

asyncio-atexit's Issues

uvloop compatibility

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'>

Breaks with nest-asyncio

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?

Minimal reproducible example

Before

# 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

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.