Closed cooperlees closed 4 years ago
Would you prefer me to have the function return aiohttp's coroutine?
I mainly care here cause I have another PR ready to go to add aenter and aexit for async gernerator support. This will help me clean up this code:
https://github.com/pypa/bandersnatch/blob/master/src/bandersnatch/master.py#L145
(I'd also like to get the USER_AGENT easier too so I can modify it - But that will come after this :))
As stated on the PRs, I'd really like to reduce the amount of code I need in bandersnatch to use your library. I feel this will benefit many other users and future users. My end goal is adding aenter and aexit to your class so I can just async with
in bandersnatch and significantly reduce the lines of code.
A second goal is to also make it easier to change the USER_AGENT header for queries. We do this so metrics generated can be used to easily identify Mirroring traffic as opposed to CI / real humans.
Also, I'd love to at least see the integration tests in bandersnatch's CI pass in order to be confident your proposals actually work.
Would you accept a separate async def aclose()
coroutine/method that I can then use with the __aenter__
and __aexit__
I'd like to add in a follow up PR?
To closing the session you should use an original close (from master branch) prefixed with await
keyword.
Ok, so I've tried as your wished in this commit in the close_xml_rpc
branch:
As you can see CI passes, but when you add PYTHONFAULTHANDLER=yes
and PYTHONWARNINGS=once
you see the connections are not actually closed. To illustrate this I set these on to bandersnatch's Travis 3.8 Integration run:
This CI job reports that the connections are not getting closed. Here is a paste of the errors: https://pastebin.com/J9Fm2mnc
If I revert these changes and keep PYTHONFAULTHANDLER=yes
+ PYTHONWARNINGS=once
, the connections are no longer reported as unclosed.
This is why I submitted the PR. How do you want to fix this and allow people to actually close connections?
Found https://github.com/aio-libs/aiohttp/issues/111
Moved to more correctly using my shared ClientSession. Don't need this PR.
Addresses parts of #27