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

Default connect timeout doesn't work #50

Closed
Lenka42 opened this issue Jun 7, 2019 · 4 comments
Closed

Default connect timeout doesn't work #50

Lenka42 opened this issue Jun 7, 2019 · 4 comments

Comments

@Lenka42
Copy link

Lenka42 commented Jun 7, 2019

I have a problem with connect operation not terminating after timeout. For example you can try to connect to wrong port:

import asyncio
import aiosmtplib
loop = asyncio.get_event_loop()
smtp = aiosmtplib.SMTP('smtp-mail.outlook.com', 5871, use_tls=True)
async def connect_and_print(smtp):
    await smtp.connect()
    print('connected')
loop.run_until_complete(connect_and_print(smtp))

This code hangs for a long-long time. I also tried to wrap connect into asyncio.wait_for but it also doesn't work.

@cole
Copy link
Owner

cole commented Jun 7, 2019

There is a bug (no open issue for it, but it's already been fixed in the dev branch) in 1.0.5 where the docs specify the default timeout as 60 seconds but it's actually None (so unlimited). Sorry about that. You can specify a timeout manually though:

import asyncio
import aiosmtplib
loop = asyncio.get_event_loop()
smtp = aiosmtplib.SMTP('smtp-mail.outlook.com', 5871, use_tls=True, timeout=10.0)
async def connect_and_print(smtp):
    await smtp.connect()
    print('connected')
loop.run_until_complete(connect_and_print(smtp))

@decaz
Copy link

decaz commented Jun 10, 2019

@cole is it known when next release which includes this fix will be available?

@cole
Copy link
Owner

cole commented Jun 10, 2019

@decaz not yet. I'd recommend you specify a timeout manually (60 will be the future default).

@cole cole changed the title Connect timeout doesn't work Default connect timeout doesn't work Jun 10, 2019
@cole
Copy link
Owner

cole commented Jun 17, 2019

The default is now 60 seconds in 1.0.6.

@cole cole closed this as completed Jun 17, 2019
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

3 participants