[issue23548] TypeError in event loop finalizer, new in Python 3.4.3

William Woodall report at bugs.python.org
Wed Apr 8 06:05:32 CEST 2015


William Woodall added the comment:

I was getting the same error as the OP in my application.

I did something like this to work around the problem:

import asyncio
import atexit

def close_asyncio_loop():
    loop = None
    try:
        loop = asyncio.get_event_loop()
    except AttributeError:
        pass
    if loop is not None:
        loop.close()

atexit.register(close_asyncio_loop)

Is this an appropriate work around?

Why is it up to the application to close the loop explicitly?

Put another way, in what scenario would I want to close the loop outside of the application shutting down since it is irreversible?

Thanks in advance for your time.

----------
nosy: +wjwwood

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue23548>
_______________________________________


More information about the Python-bugs-list mailing list