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

AtributeError: 'NoneType' object has no attribute 'resume_reading' #726

Open
polin924fbn opened this issue Mar 26, 2021 · 4 comments
Open
Assignees

Comments

@polin924fbn
Copy link

polin924fbn commented Mar 26, 2021

  • asyncpg version: 0.22.0
  • PostgreSQL version: 12
  • Do you use a PostgreSQL SaaS? If so, which? Can you reproduce
    the issue with a local PostgreSQL install?
    : Yes
  • Python version: 3.8
  • Platform: Linux
  • Do you use pgbouncer?: No
  • Did you install asyncpg with pip?: Yes
  • If you built asyncpg locally, which version of Cython did you use?: 3.8?
  • Can the issue be reproduced under both asyncio and
    uvloop?
    : Yes

I saw this issue AtributeError: 'NoneType' object has no attribute 'resume_reading'.
Below is the sample code we use. The version of aiohttp is 3.7.4.post0

from aiohttp.web_response import StreamResponse 
from aiohttp.web_request import Request 
import asyncpg.pool

async def test_get_response(req: Request)
	pool = await asyncpg.create_pool(database='xxx', user='xxx', ....)

	sql = '''
	xxx
	'''
	async with pool.acquire() as db_conn:
	        response = StreamResponse()
	        response.headers.add('Content-Type', 'text/csv; charset=utf-8')
	        await response.prepare(req)
	        await db_conn.copy_from_query(
	            sql,
	            header=True,
	            format='csv',
	            output=response.write
	        )
	        return response

Below is the exception.

File "/root/.local/share/virtualenvs/xxxx/lib/python3.8/site-packages/asyncpg/connection.py", line 784, in copy_from_query
return await self._copy_out(copy_stmt, output, timeout)
File "/root/.local/share/virtualenvs/xxxx/lib/python3.8/site-packages/asyncpg/connection.py", line 989, in _copy_out
return await self._protocol.copy_out(copy_stmt, writer, timeout)
......
File "asyncpg/protocol/protocol.pyx", line 359, in copy_out
File "asyncpg/protocol/protocol.pyx", line 132, in asyncpg.protocol.protocol.BaseProtocol.resume_reading
File "/usr/local/lib/python3.8/asyncio/sslproto.py", line 344, in resume_reading
self._ssl_protocol._transport.resume_reading()
AttributeError: 'NoneType' object has no attribute 'resume_reading'

We don’t have a good repro - someone who knows the code might have a good idea about why it happens?

thanks

@elprans
Copy link
Member

elprans commented Mar 26, 2021

Looks like a connection got dropped in the middle and that fact got lost somehow.

@elprans
Copy link
Member

elprans commented Mar 26, 2021

@fantix, this seems to be SSL-related. Any ideas?

@Reskov
Copy link

Reskov commented Apr 6, 2021

I face a similar problem with asyncpg 0.22.0 and RDS.
Also, I can't reproduce this problem locally without SSL, or with asyncpg 0.21.0

<PoolConnectionProxy [released] 0x7fe2e539b820>
AttributeError: 'NoneType' object has no attribute '_protocol'

@cbrichford
Copy link

cbrichford commented Sep 10, 2021

I tracked this down. This is a bug in the asyncio ssl support in the python runtime. A work around is to switch to uvloop (https://github.com/MagicStack/uvloop).
https://bugs.python.org/issue45159?@ok_message=msg%20401553%20created%0Aissue%2045159%20created&@template=item

@fantix In light of this, you may want close this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants