New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Traceback in debug mode due to pending aiohttp connections #25
Comments
Thanks! I like your idea of using the context manager or
|
Correct. I agree it is not a show-stopping problem but needs fixing regardless.
Yes. I hacked it into the generated classes to proof this would work but I have never used swagger-codegen before. Do you have an ETA for this, by chance? |
Did you manage to make this work? I'm really interested in a graceful shutdown method. I'm not sure to understand. Does this depends on an external project API change or can be done in this one? |
@mickours Could you show your use case? It it related to Watch or Stream ? |
The issue is already fixed in 11.2.0. There are the context manager and the |
From what I have found out so far this is because
RESTClientObject
relies on its__del__
method to be called before the event loop terminates. This is flakey since Python makes no guarantee to call that method at all.A quick way to reproduce the problem on my Python 3.6 machine is to add this test to
test_watch.py
and run it in debug mode ie (export PYTHONASYNCIODEBUG=1
):This produces a lengthy stack trace, but the salient part is this:
The problem does not materialise if I change
to
because
__del__
will be called immediately, presumably because Python garbage collects the object immediately since nothing ever references it.As a first attempt to address the problem I added an explicit
shutdown
method toRESTClientObject
and all the classes that instantiate it up to
Watch
. Users must then explicitly callWatch().stream(...).shutdown()
or use the context manager I created for it. This feels inelegant and is a maintenance burden. Ideally, we could register a callback inRESTClientObject
that triggers whenever the event loop shuts down because that is when we need to close pending connections. Any ideas?I should probably point out that users will not see the stack trace unless they run in debug mode, but I would still like a clean solution for this because I am petty 😄
The text was updated successfully, but these errors were encountered: