Code Monkey home page Code Monkey logo

Comments (14)

decaz avatar decaz commented on May 15, 2024

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.

cole avatar cole commented on May 15, 2024

Thanks for filing. Is this consistently reproducible? Any change you could provide a sample that triggers it?

from aiosmtplib.

decaz avatar decaz commented on May 15, 2024

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.

cole avatar cole commented on May 15, 2024

That was it, exactly. Can you try again with 8f7a011?

from aiosmtplib.

decaz avatar decaz commented on May 15, 2024

Just updated to the last revision, - no errors yet visible.

from aiosmtplib.

decaz avatar decaz commented on May 15, 2024

@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.

cole avatar cole commented on May 15, 2024

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.

decaz avatar decaz commented on May 15, 2024

@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.

cole avatar cole commented on May 15, 2024

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.

decaz avatar decaz commented on May 15, 2024

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.

cole avatar cole commented on May 15, 2024

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.

cole avatar cole commented on May 15, 2024

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.

decaz avatar decaz commented on May 15, 2024

@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.

decaz avatar decaz commented on May 15, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.