Open d21d3q opened 5 years ago
Maybe we could catch AttributeError
along with ConnectionResetError
or check/assert before writing if there is self.writer
- if not raise ConnectionResetError
(since writer can be None only in case of closed connection)?
I am observing this bug on client publishing approx every second in long run. Following tracelog contains some timings (from kibana):
This line is interesting:
I guess error happens in . Since error happens around disconnection time, it would mean that detach method (which can set
writer
toNone
) is being between checking if clint is connected and writing packetto_stream
, called from handler.I noticed commented out
yield from self._handler.stop()
, I guess that it is meant to make som cleanup?Question is what should happen to packet being interrupted by disconnection? Coroutine should be cancelled and rescheduled to be run again on connect? Or publish task should rise something, so that user can handle retransmission on his own. Since disconnect occurs before
write
, so it could be rescheduled automatically (broker doesn't know about it yet).That would require keeping track on all pending packets (pings, publishes etc)