qpid-proton icon indicating copy to clipboard operation
qpid-proton copied to clipboard

NO-JIRA: [Python] Fix exception in IOHandler.on_selectable_expired/update

Open Jmennius opened this issue 3 years ago • 5 comments

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

Jmennius avatar Apr 07 '22 09:04 Jmennius

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'

Jmennius avatar Apr 14 '22 12:04 Jmennius

Codecov Report

Merging #364 (4d22a80) into main (a920192) will increase coverage by 20.11%. The diff coverage is n/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     
Impacted Files Coverage Δ
python/proton/_handlers.py
python/tests/proton_tests/__init__.py
cpp/src/ssl_options_impl.hpp
python/proton/utils.py
c/src/core/object/object.c
cpp/include/proton/endpoint.hpp
c/tests/object_test.cpp
python/proton/_selectable.py
c/src/reactor/reactor.c
cpp/include/proton/reconnect_options.hpp
... and 310 more

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update a920192...4d22a80. Read the comment docs.

codecov-commenter avatar May 02 '22 06:05 codecov-commenter

@astitcher What do you think? Should I open an issue?

Jmennius avatar May 05 '22 17:05 Jmennius

Could we get this PR merged? I ran into the bug recently. It causes qpid proton to be pretty unusable.

itechbear avatar Nov 19 '23 06:11 itechbear

I've opened a Jira issue for this https://issues.apache.org/jira/browse/PROTON-2776. I can work on the PR if ncessary.

Jmennius avatar Nov 20 '23 10:11 Jmennius