Are you using Python3? Then there's "asynchronous context managers". I
finally found a use-case for one in txtorcon, so here's an example:
http://txtorcon.readthedocs.io/en/latest/txtorcon-controller.html#txtorcon.Tor.onion_authentication
--
meejah
I have a context manager whose __exit__ method needs to run some asynchronous
Twisted code. Using Crochet's @wait_for very nearly works:
no_setup()
class Example(object):
def __exit__(t, v, tb):
return self.cleanup()
@wait_for
@inlineCallbacks
def cleanup(self):