Skip to content
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

Error in ClientSession __del__ #497

Closed
sk- opened this issue Sep 8, 2015 · 6 comments
Closed

Error in ClientSession __del__ #497

sk- opened this issue Sep 8, 2015 · 6 comments
Assignees
Milestone

Comments

@sk-
Copy link

sk- commented Sep 8, 2015

The __del__ method of ClientSession available for Python >= 3.4.1 produces inconsistent tracebacks.
I'm using Aiohttp 0.17.3 on Mac Os X Yosemite, with Python 3.4.3.

With the same code I've seen the following ones:
(Note: this same code was working fine with aiohttp 0.16.5 and it also works if I just comment out https://github.com/KeepSafe/aiohttp/blob/b6bfb7afbe1b786ca396757c5a88c3822fc4057a/aiohttp/client.py#L79-L90)

Exception ignored in: <bound method ClientSession.__del__ of <aiohttp.client.ClientSession object at 0x101975b70>>
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/aiohttp/client.py", line 77, in __del__
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/aiohttp/client.py", line 342, in close
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/aiohttp/connector.py", line 235, in close
TypeError: 'NoneType' object is not callable
Exception ignored in: <bound method ClientSession.__del__ of <aiohttp.client.ClientSession object at 0x102075b70>>
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/aiohttp/client.py", line 79, in __del__
AttributeError: 'NoneType' object has no attribute 'warn'
Exception ignored in: <bound method ClientSession.__del__ of <aiohttp.client.ClientSession object at 0x102175b70>>
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/aiohttp/client.py", line 80, in __del__
TypeError: 'NoneType' object is not callable
Exception ignored in: <bound method ClientSession.__del__ of <aiohttp.client.ClientSession object at 0x102175b70>>
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/aiohttp/client.py", line 85, in __del__
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/asyncio/base_events.py", line 1036, in call_exception_handler
AttributeError: 'NoneType' object has no attribute 'error'
@asvetlov asvetlov added this to the 0.18 milestone Sep 8, 2015
@asvetlov asvetlov self-assigned this Sep 8, 2015
@asvetlov
Copy link
Member

asvetlov commented Sep 8, 2015

Thanks for report. It should be fixed in both aiohttp and asyncio.

@asvetlov
Copy link
Member

asvetlov commented Sep 9, 2015

This is only partial fix: the same should be done for asyncio for logger instance.

Let's leave the issue open until making asyncio fix.

@asvetlov asvetlov reopened this Sep 9, 2015
@asvetlov
Copy link
Member

asvetlov commented Sep 9, 2015

@sk for sake of best practice please don't rely on garbage collector but explicitly call session.close() after finishing all jobs for the session.

@sk-
Copy link
Author

sk- commented Sep 9, 2015

@asvetlov: Thanks for pointing out that I should close the session. I was using it in a command line crawler, and the program was terminating after completing the jobs. Closing the session fixes my problem.

@asvetlov asvetlov modified the milestones: 0.19, 0.18 Oct 19, 2015
@asvetlov asvetlov modified the milestones: 0.20, 0.19 Nov 23, 2015
@asvetlov asvetlov modified the milestones: 0.21, 0.20 Dec 29, 2015
@asvetlov asvetlov modified the milestones: 0.22, 0.21 Feb 16, 2016
@asvetlov
Copy link
Member

asvetlov commented Aug 9, 2016

I did my best, aiohttp is safe now.
But asyncio itself still may raise an issue.

@lock
Copy link

lock bot commented Oct 29, 2019

This thread has been automatically locked since there has not been
any recent activity after it was closed. Please open a new issue for
related bugs.

If you feel like there's important points made in this discussion,
please include those exceprts into that new issue.

@lock lock bot added the outdated label Oct 29, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Oct 29, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants