gmr / rabbitpy

A pure python, thread-safe, minimalistic and pythonic RabbitMQ client library
http://rabbitpy.readthedocs.org
BSD 3-Clause "New" or "Revised" License
242 stars 58 forks source link

Fix deadlock when access is denied during connect. #120

Closed dave-shawley closed 4 years ago

dave-shawley commented 4 years ago

There were two problems here:

  1. Connection.close was raising an exception instead of closing when it was in the "opening" state
  2. When an exception was raised, the channel0 lock in IO.on_read was never being released -- I'm pretty sure that this was an incidental finding, but it is something that happened

The result was the connection getting stuck waiting for channel 0 to become available in _connect. I fixed the problem by changing Connection.close to process closures when it is both open and opening.

codecov[bot] commented 4 years ago

Codecov Report

Merging #120 into master will increase coverage by 1.27%. The diff coverage is 80.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #120      +/-   ##
==========================================
+ Coverage   71.01%   72.28%   +1.27%     
==========================================
  Files          16       16              
  Lines        1880     1880              
  Branches      290      291       +1     
==========================================
+ Hits         1335     1359      +24     
+ Misses        412      394      -18     
+ Partials      133      127       -6     
Impacted Files Coverage Δ
rabbitpy/connection.py 67.42% <66.66%> (+3.32%) :arrow_up:
rabbitpy/io.py 56.49% <100.00%> (+1.47%) :arrow_up:
rabbitpy/utils.py 80.00% <0.00%> (+5.00%) :arrow_up:
rabbitpy/channel0.py 76.98% <0.00%> (+7.14%) :arrow_up:

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 73437a9...e94781a. Read the comment docs.