When attempting to execute EventSourceResponse.send(), the connection may be interrupted, resulting in a ConnectionResetError (for example, if the client closed the browser).
Already at this moment we know that the connection is closed and cannot be restored.
But EventSourceResponse._ping_task is still working... When the EventLoop pays attention to the Task, the _ping_task will try to send a : ping to the closed connection.
Because the actions performed by the Task are doomed to failure in advance, we can free him from useless work and cancel the Task on send() failure
When attempting to execute
EventSourceResponse.send()
, the connection may be interrupted, resulting in aConnectionResetError
(for example, if the client closed the browser).Already at this moment we know that the connection is closed and cannot be restored.
But
EventSourceResponse._ping_task
is still working... When the EventLoop pays attention to the Task, the_ping_task
will try to send a: ping
to the closed connection.Because the actions performed by the Task are doomed to failure in advance, we can free him from useless work and cancel the Task on
send()
failure