question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

incompatible with uvloop because of access to private attribute _protocol

See original GitHub issue

I’m using uvloop because of the significant speed up that it provides. However this seems to be incompatible with using the starttls method.

minimal example (put in actual connection information before running):

import asyncio
import uvloop
asyncio.set_event_loop_policy(uvloop.EventLoopPolicy())

import aiosmtplib

async def connect(loop):
    smtp = aiosmtplib.SMTP(
        loop=loop,
        hostname=localhost,
        port=port,
        use_tls=True)
    await smtp.connect(use_tls=False, port=port)
    await smtp.starttls(validate_certs=False)

if __name__ == "__main__":
    loop = asyncio.get_event_loop()
    loop.run_until_complete(connect(loop))

result

Traceback (most recent call last):
  File "minimal_example.py", line 19, in <module>
    loop.run_until_complete(connect(loop))
  File "uvloop/loop.pyx", line 1203, in uvloop.loop.Loop.run_until_complete (uvloop/loop.c:25632)
  File "minimal_example.py", line 15, in connect
    await smtp.starttls(validate_certs=False)
  File "/git/dnd/lib64/python3.6/site-packages/aiosmtplib/esmtp.py", line 193, in starttls
    tls_context, server_hostname=server_hostname, timeout=timeout)
  File "/git/dnd/lib64/python3.6/site-packages/aiosmtplib/protocol.py", line 209, in starttls
    tls_context, server_hostname=server_hostname, waiter=waiter)
  File "/git/dnd/lib64/python3.6/site-packages/aiosmtplib/protocol.py", line 82, in upgrade_transport
    self.reader._transport._protocol = tls_protocol  # type: ignore
AttributeError: 'uvloop.loop.TCPTransport' object has no attribute '_protocol'

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
colecommented, Mar 27, 2017

Hmmm, uvloop seems to handle protocols and transports a bit differently internally.

Unfortunately there is no public API to upgrade an asyncio connection in place yet, so it’s understandable that uvloop behaves differently. I’ll see if I can find a way to get it working.

0reactions
nihlaethcommented, Apr 7, 2017

Thanks!

Read more comments on GitHub >

github_iconTop Results From Across the Web

incompatible with uvloop because of access to ... - GitHub
I'm using uvloop because of the significant speed up that it provides. However this seems to be incompatible with using the starttls method....
Read more >
python-websockets(1) - Arch manual pages
The WebSocket protocol provides two-way communication between a browser and a server over a persistent connection. That's exactly what you need to exchange ......
Read more >
'uvloop' has no attribute 'EventLoopPolicy' - Stack Overflow
It's pesky because (at least on CentOS) some pip-installed Python packages go in /usr/local/lib/python3.7/site-packages and some go in /usr/ ...
Read more >
Release 4.10 David Cortesi - PyInstaller Documentation
If your program depends on access to certain data files, ... Note: PyInstaller currently does not preserve file attributes. see #3926.
Read more >
v3.7.3 PDF - aiohttp Documentation
Because the content attribute is a StreamReader (provides async iterator protocol), you can chain get and post requests together:.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found