Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Jmennius
Copy link
Contributor

@Jmennius Jmennius commented Apr 7, 2022

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
Copy link
Contributor Author

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-commenter
Copy link

codecov-commenter commented May 2, 2022

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.

@Jmennius
Copy link
Contributor Author

Jmennius commented May 5, 2022

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

…date

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()`.

Signed-off-by: Ievgen Popovych <[email protected]>
@Jmennius Jmennius force-pushed the python-fix-exception-IOHandler-on_selectable_expired branch from 4d22a80 to 8b75942 Compare March 1, 2023 18:09
@itechbear
Copy link

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

@Jmennius
Copy link
Contributor Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants