1. 05 Oct, 2016 1 commit
  2. 28 Feb, 2015 1 commit
  3. 23 Feb, 2015 1 commit
    • mathieui's avatar
      Add a coroutine_wrapper decorator · 8fd0d7c9
      mathieui authored
      This decorator checks for the coroutine=True keyword arg and wraps the
      result of the function call in a coroutine if it isn’t.
      
      This allows to have constructs like:
      
      @coroutine_wrapper
      def toto(xmpp, *, coroutine=False):
          if xmpp.cached:
              return xmpp.cached
          else:
              return xmpp.make_iq_get().send(coroutine=coroutine)
      
      @asyncio.coroutine
      def main(xmpp):
          result = yield from toto(xmpp, coroutine=True)
          xmpp.cached = result
          result2 = yield from toto(xmpp, coroutine=True)
      
      If the wrapper wasn’t there, the second fetch would fail. This decorator
      does not do anything if the coroutine argument is False.
      8fd0d7c9
  4. 05 Jan, 2015 1 commit
  5. 03 Jan, 2015 2 commits