Latest commit 9598b43 Mar 1, 2016 @vitaly-krugl vitaly-krugl Fixed channel-related bugs discovered through code review in Channel
and Connection classes; implemented new tests to verify fixes:

    - When closing a Channel, skip auto-cancellation of consumers that are already being
    - Fix race condition, whereby Channel.Close comes in from broker while the channel
      is in CLOSING state expecting Channel.CloseOk, by waiting for CloseOk before
      notifying user and cleaning up, to make sure that channel number won't
      get reused before the expected CloseOk arrives.
    - Fixed basic_cancel and confirm_delivery with nowait=True (used to choke with
      ValueError in Channel._rpc).
    - When connection dies while unclosed channels remain, Connection._on_terminate now
      calls Channel._on_close_meta to properly clean up the remaining channels.
    - Fixed Channel.close to work with channel that is in the OPENING state. This allows
      Connection.close to properly get all channels closed, not just the ones in OPEN
      state. And it seems reasonable in general for it to work this way. If channel is
      OPENING, transition to CLOSING and suppress the incoming Channel.OpenOk.

Behavior changes:
    - Removed the deprecated `type` arg from `BlockingChannel.exchange_declare` and
    - In Connection._deliver_frame_to_channel(), consider it a critical protocol
      breach if received frame for channel not in our channel set. Log it at
      critical level, instead of trying to screen for Basic.Deliver and reject.
    - In Channel.close(), if channel is already CLOSING, raise ChannelAlreadyClosing
      exception. Legacy behavior used to raise ChannelClosed.
    - Raise `ConnectionClosed` in `` if connection is not in OPEN

Removed obsolete functionality:
    - Removed Channel._pending and related code, since this functionality was in support
      of the legacy BlockingConnection, which has since been rewritten.
    - Removed _write_lock from Connection; Connection is not thread-safe by design,
      and the lock was not protecting all output buffer accesses anyway.
    - In Channel constructor, remove the default value from on_open_callback, since
      Channel is only instantiated by Connection, which always passes this arg

Cleaned up logic related to auto-closing of channels while closing a connection.

When cancelling a consumer with nowait=True, remove its consumer entry from
self._consumers to help garbage collection; otherwise, it wouldn't get purged
until the channel is closed.

Implemented a dedicated method Channel._on_close_meta to handle the meta-close
request from Connection._on_terminate logic to avoid overloading the Channel.Close method
handler's logic.

More unit test for Channel and Connection that cover channel and connection closing

Fix a couple of invalid heartbeat and tornado unit test methods.

Cleaned up method_frame vs. method args in Channel and fixed docstrings; in a number of
cases an arg named method_frame was being used to pass an AMQP method prior to this

Misc. docstring fixup in both Channel and Connection classes concerning arg types, return
values and raised exceptions.

Renamed channel.ContentFrameDispatcher as channel.CotentFrameAssembler
to reflect its actual functionality, and renamed the corresponding member to

Cleaned up many pylint findings in related modules and tests.

Fixed several style issues per @gmr's code review feedback in PR #712.
Also, tagged the backpressure_detection option as deprecated in connection parameters
per @gmr's suggestion in PR #714.