Comments (14)
And another one:
InvalidStateError: invalid state
File "asyncio/selector_events.py", line 813, in _read_ready__data_received
self._protocol.data_received(data)
File "aiosmtplib/protocol.py", line 107, in data_received
self._response_waiter.set_result(response)
from aiosmtplib.
Thanks for filing. Is this consistently reproducible? Any change you could provide a sample that triggers it?
from aiosmtplib.
Yes, the first case is very common but the second is rare. I'm just using await aiosmtplib.send(...)
and nothing more. Exceptions are caught using loop exception handler: loop.set_exception_handler(...)
.
Didn't dig in the aiosmtplib
code but maybe <future>.done()
checks are missing before <future>.set_result(...)
or <future>.set_exception(...)
is called?
from aiosmtplib.
That was it, exactly. Can you try again with 8f7a011?
from aiosmtplib.
Just updated to the last revision, - no errors yet visible.
from aiosmtplib.
@cole unfortunately just got the second case exception:
InvalidStateError: invalid state
File "asyncio/selector_events.py", line 813, in _read_ready__data_received
self._protocol.data_received(data)
File "aiosmtplib/protocol.py", line 102, in data_received
self._response_waiter.set_result(response)
from aiosmtplib.
Huh, I still don't really understand why data_received
is getting multiple complete responses without the waiter being awaited in between. We can just put in a check for done
but I think there might be a larger problem here.
Can you try with db7ab6? It won't fix the issue, but it adds a clearer exception.
from aiosmtplib.
@cole just got it three times in a row:
RuntimeError: data_received called with an unexpected response waiter state: <Future finished result=(250, 2.1.5 Ok)> (data: b'221 2.0.0 Bye\r\n')
File "asyncio/selector_events.py", line 813, in _read_ready__data_received
self._protocol.data_received(data)
File "aiosmtplib/protocol.py", line 94, in data_received
"{!r} (data: {})".format(self._response_waiter, data)
from aiosmtplib.
Huh, ok, it looks like I've just an unprompted server disconnect (timeout maybe)? I've put a check in for _response_waiter.done()
so you shouldn't see the error anymore.
Thanks for helping debug this.
from aiosmtplib.
Another case of this exception with new text:
RuntimeError: data_received called with an unexpected response waiter state: <Future cancelled> (data: b'220 my.host.ru ESMTP MTA\r\n')
File "asyncio/selector_events.py", line 813, in _read_ready__data_received
self._protocol.data_received(data)
File "aiosmtplib/protocol.py", line 94, in data_received
"{!r} (data: {})".format(self._response_waiter, data)
from aiosmtplib.
That is more confusing — that future is only cancelled in connection_lost
, and data_received
should not be called after connection_lost
. I'll investigate further.
from aiosmtplib.
Just to confirm, are you stopping/starting the event loop or anything?
I don't understand why it is happening, but it looks like in the remaining error case, the connection is already closing as we get a EHLO response — in that case we can just discard the message.
from aiosmtplib.
@cole nope, nothing unusual with event loop.
But sometimes I'm getting the following timeout exception from server:
SMTPReadTimeoutError
Timed out waiting for server response
Maybe this could lead to SMTPProtocol.connection_lost
was called at the client side while SMTPProtocol.data_received
was suddenly called.
But the case with RuntimeError
(cancelled future) happened just once.
from aiosmtplib.
I think we can close it for now because there are no any new exceptions raised at this moment. @cole thanks!
from aiosmtplib.
Related Issues (20)
- TypeError: connect() takes 1 positional argument but 2 were given HOT 3
- Source Address is not used in socket connection HOT 5
- Support URL for connection HOT 1
- CancelledError thrown when trying to send without authentication HOT 2
- Enabling UTF-8 for Authetication HOT 5
- 4 failing tests HOT 7
- add github issues url to bug reporting docs section HOT 1
- [Debian] Please include CHANGELOG.rst in your pypi releases. HOT 2
- Please support choice of outbound IP address HOT 1
- Suggestion: Support 'TLS optional' usage HOT 3
- Add testing section to docs HOT 2
- Timed out waiting for server ready message HOT 3
- Error trying to use the mail_options or rcpt_options arguments HOT 1
- Do not receive emails using Bcc, Cc headers HOT 2
- Custom DNS resolver HOT 1
- aiosmtplib is not working. [SSL: WRONG_VERSION_NUMBER] wrong version number HOT 1
- packaging issue: deployment of tests HOT 1
- Operation-level timeout HOT 4
- Gives AttributeError when calling with when HOT 2
- Support LMTP HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from aiosmtplib.