core: make Receiver a self-closing context manager.

issue510
David Wilson 6 years ago
parent fcc403cc2f
commit 84f75551a3

@ -813,6 +813,12 @@ class Receiver(object):
def __repr__(self): def __repr__(self):
return 'Receiver(%r, %r)' % (self.router, self.handle) return 'Receiver(%r, %r)' % (self.router, self.handle)
def __enter__(self):
return self
def __exit__(self, _1, _2, _3):
self.close()
def to_sender(self): def to_sender(self):
""" """
Return a :class:`Sender` configured to deliver messages to this Return a :class:`Sender` configured to deliver messages to this

Loading…
Cancel
Save