NO-JIRA: [Python] Fix exception in IOHandler.on_selectable_expired/update
This occasionally happens after my laptop wakes up from overnight sleep.
IOHandler.on_selectable_expired() is invoked with selectable that has
_terminated=True and _transport=None so when IOHandler.update()
is called it crashes when trying to handle the exception
(since transport is None).
Fix this by checking if transport attribute is set and that selectable is not
terminated before invoking IOHandler.update().
PROTON Jira issue: https://issues.apache.org/jira/browse/PROTON-2776
Here is a traceback:
Traceback (most recent call last):
File "/path/.venv/lib/python3.7/site-packages/proton/_handlers.py", line 1293, in update
capacity = transport.capacity()
AttributeError: 'NoneType' object has no attribute 'capacity'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/path/my-project.py", line 285, in run
self.container.run()
File "/path/.venv/lib/python3.7/site-packages/proton/_reactor.py", line 197, in run
while self.process():
File "/path/.venv/lib/python3.7/site-packages/proton/_reactor.py", line 262, in process
event.dispatch(self._global_handler)
File "/path/.venv/lib/python3.7/site-packages/proton/_events.py", line 158, in dispatch
_dispatch(handler, type.method, self)
File "/path/.venv/lib/python3.7/site-packages/proton/_events.py", line 131, in _dispatch
handler.on_unhandled(method, *args)
File "/path/.venv/lib/python3.7/site-packages/proton/_reactor.py", line 905, in on_unhandled
event.dispatch(self.base)
File "/path/.venv/lib/python3.7/site-packages/proton/_events.py", line 158, in dispatch
_dispatch(handler, type.method, self)
File "/path/.venv/lib/python3.7/site-packages/proton/_events.py", line 129, in _dispatch
m(*args)
File "/path/.venv/lib/python3.7/site-packages/proton/_handlers.py", line 1237, in on_selectable_expired
self.update(t, s, r.now)
File "/path/.venv/lib/python3.7/site-packages/proton/_handlers.py", line 1296, in update
if transport.closed:
AttributeError: 'NoneType' object has no attribute 'closed'
Codecov Report
Merging #364 (4d22a80) into main (a920192) will increase coverage by
20.11%. The diff coverage isn/a.
@@ Coverage Diff @@
## main #364 +/- ##
===========================================
+ Coverage 68.24% 88.36% +20.11%
===========================================
Files 367 47 -320
Lines 73285 2397 -70888
===========================================
- Hits 50011 2118 -47893
+ Misses 23274 279 -22995
Continue to review full report at Codecov.
Legend - Click here to learn more
Δ = absolute <relative> (impact),ø = not affected,? = missing dataPowered by Codecov. Last update a920192...4d22a80. Read the comment docs.
@astitcher What do you think? Should I open an issue?
Could we get this PR merged? I ran into the bug recently. It causes qpid proton to be pretty unusable.
I've opened a Jira issue for this https://issues.apache.org/jira/browse/PROTON-2776. I can work on the PR if ncessary.