Giter Site home page Giter Site logo

Comments (5)

awestendorf avatar awestendorf commented on July 17, 2024

Good stuff. The "set to None" is there to help reference counting clean up channels under high load without relying on the garbage collector. I'll work on fixing this.

from haigha.

awestendorf avatar awestendorf commented on July 17, 2024

I think a good way to way to solve this would be to restructure the code in a try-finally block and document clearly that the listeners will be able to access the channel attributes at call time but they'll be out of scope after that.

The close listeners are brand new as I needed them to fix a variety of problems in the ChannelPool so please keep writing up bugs for anything associated with them.

  def _closed_cb(self, final_frame=None):
    if final_frame:
      self._connection.send_frame( final_frame )

    try:
      for listener in self._close_listeners:
        listener( self )
    finally:
      self._pending_events = deque()
      self._frame_buffer = deque()

      for protocol_class in self._class_map.values():
        protocol_class._cleanup()

      self._connection = None
      self.channel = None
      self.exchange = None
      self.queue = None
      self.basic = None
      self.tx = None
      self._class_map = None
      self._close_listeners = set()

from haigha.

vitaly-krugl avatar vitaly-krugl commented on July 17, 2024

That looks very reasonable. I think that this also needs to be complimented with a small change in Channel class that allows the user to access the ch.closed attribute at any time without crashing. Perhaps something like this:


  @property
  def closed(self):
    return self.channel is None or self.channel.closed


# Usage example
if not ch.closed:
    ch.close()

from haigha.

vitaly-krugl avatar vitaly-krugl commented on July 17, 2024

The user would also need to know that their last opportunity to extract close_info is in the close-listener callback. However, in my code, I also wished I could to do something like this from anywhere:

if ch.closed:
    self._logger.error("Channel closed unexpectedly; close_info: %r", ch.close_info)

from haigha.

awestendorf avatar awestendorf commented on July 17, 2024

Fixed this in master by moving all channel state into Channel and out of ChannelClass. Will go out with the next release later today.

from haigha.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.