<html>
  <head>
    <meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <p>I played with it some time ago. Actually, <a
        href="https://github.com/python/cpython/blob/master/Lib/contextlib.py">original
        code</a> with few changes works fine.</p>
    <p>Here's example:<br>
    </p>
    <p><a
        href="https://gist.github.com/germn/6b2f8a1afbfc322daa01365cacd1d9ad">https://gist.github.com/germn/6b2f8a1afbfc322daa01365cacd1d9ad</a></p>
    <p>Test it:</p>
    <blockquote>
      <p>import asyncio<br>
        from acontextlib import acontextmanager<br>
        <br>
        <br>
        state = []<br>
        <br>
        @acontextmanager<br>
        async def woohoo():<br>
            state.append(1)<br>
            yield 42<br>
            state.append(999)<br>
        <br>
        <br>
        async def main():<br>
            async with woohoo() as x:<br>
                assert state == [1]<br>
                assert x == 42<br>
        <br>
        <br>
        if __name__ == '__main__':<br>
            loop = asyncio.get_event_loop()<br>
            loop.run_until_complete(main())<br>
      </p>
    </blockquote>
    <p><br>
    </p>
    <p><br>
    </p>
    <br>
    <div class="moz-cite-prefix">01.11.2016 19:15, Federico Marani
      пишет:<br>
    </div>
    <blockquote
cite="mid:CAON9gVaziyDp-07_9EwvsGHVw9rjkym17zUiRiRCcokX4cyeiw@mail.gmail.com"
      type="cite">
      <div dir="ltr">
        <div>Has anyone tried to build an asynchronous version of
          @contextmanager? Is it even possible... given the use of
          yield?</div>
      </div>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <br>
      <pre wrap="">_______________________________________________
Async-sig mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Async-sig@python.org">Async-sig@python.org</a>
<a class="moz-txt-link-freetext" href="https://mail.python.org/mailman/listinfo/async-sig">https://mail.python.org/mailman/listinfo/async-sig</a>
Code of Conduct: <a class="moz-txt-link-freetext" href="https://www.python.org/psf/codeofconduct/">https://www.python.org/psf/codeofconduct/</a></pre>
    </blockquote>
    <br>
  </body>
</html>