-
Notifications
You must be signed in to change notification settings - Fork 48
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
SMTP.quit produces warning "Future exception was never retrieved" #112
Comments
Last two lines meaning?
|
Because "Future exception was never retrieved" happens only if after calling quit passed at least a few seconds. |
I get the same error with pytest test (using pytest-asyncio), for my tests it use gmail smtp with tls (if that matters) setting
By the way, the mail is sent, even with the exception. |
OK, trying to have a look at the problem, I just discovered this does not happen every time, I just ran my test bench twice in a row, (full stop start, not twice the same test in code), first time was without problem, the second one has the error... so it something not so easy to reproduce to test... |
I'm not 100% sure but, it seems that it depends when the garbage collectors kick because, if I put some print statement in |
I'm kind of stuck on a fix for this, since this isn't very reproducible (depends on when garbage collection happens relative to loop shutdown). Note though that the warning should be harmless. |
Hi, I reproduced this issue:
I think the issue is not in my code and indeed is random and must be related with garbage collection. edit: I use version 1.1.6 |
I can reliably reproduce this issue with the following code based on the docs. Python 3.11.2 import asyncio
from email.message import EmailMessage
import aiosmtplib
async def send_hello_world():
message = EmailMessage()
message["From"] = "gmailemail@gmail.com"
message["To"] = "gmailemail@gmail.com"
message["Subject"] = "Hello World!"
message.set_content("Sent via aiosmtplib")
await aiosmtplib.send(
message,
hostname="smtp.gmail.com",
port=587,
username="gmailemail@gmail.com",
password="used app password here"
)
print("Error happens after this print!")
asyncio.run(send_hello_world())
print("End of error!") |
Same problem for me... |
Oh nice, at least it's consistent on 3.11.2. Can you try the current main branch? I've made a change that fixes it for me. |
I tried the new branch and the problem is still present with 3.11.2 on windows. Also tried with 3.10.12 on a linux VM and ran into the inconsistency problem, although it still happened. However, I also found a way to avoid the problem: import asyncio
from email.message import EmailMessage
import aiosmtplib
async def send_hello_world():
message = EmailMessage()
message["From"] = "gmailemail@gmail.com"
message["To"] = "gmailemail@gmail.com"
message["Subject"] = "Hello World!"
message.set_content("Sent via aiosmtplib")
await aiosmtplib.send(
message,
hostname="smtp.gmail.com",
port=587,
username="gmailemail@gmail.com",
password="used app password here"
)
print("Error doesn't happens after this print!")
loop = asyncio.get_event_loop()
loop.run_until_complete(send_hello_world())
print("No error!") I'm still very new to concurrency and the asyncio lib, so I'm not really sure why this works...? |
Reproduced on 3.10, 3.11 and 3.12 with aiosmtplib 3.0.0. |
I can confirm that I have that issue too. |
Reproduced on 3.10.9, with aiosmtplib 3.0.0. 😞 |
I'm still not sure how exactly that race condition is happening, but I did remove some |
can confirm, latest master version does not produce the error. |
The |
I'm eagerly awaiting the patch. Thank you for your prompt responses and work :) |
3.0.1 is out 🙂 |
Unfortunately, sometimes the issue occurs again...
python 3.11.6 |
@dokime7 any steps to reproduce? |
No sorry, it's random... |
Python 3.11.9 , aiosmtplib 3.0.2 “aiosmtplib.errors.SMTPServerDisconnected: Unexpected EOF received” will not appearloop = asyncio.get_event_loop() use like this , appearasyncio.run(send_email_by_attachment()) |
I ported this code from my old implementation on standard smtplib module, and perhaps it is not correct for aiosmtplib.
But i think this shouldn't matter.
The text was updated successfully, but these errors were encountered: