code: def timesout(deftimeout=5.0):
      
      def decorate(fn):
          assert asyncio.iscoroutinefunction(fn), "Place @timesout before @coroutine"
  
          @wraps(fn)
          @asyncio.coroutine
          def wrapper(*args, timeout=deftimeout, **kws):
              loop = kws.get('loop')
              fut = fn(*args, **kws)
              if timeout is None:
                  yield from fut
              else:
                  yield from asyncio.wait_for(fut, timeout=timeout, loop=loop)
          return wrapper
      return decorate
docs: Decorate a coroutine to implement an overall timeout.
  
      The decorated coroutine will have an additional keyword
      argument 'timeout=' which gives a timeout in seconds,
      or None to disable timeout.
  
      :param float deftimeout: The default timeout= for the decorated coroutine.
  
      It is suggested perform one overall timeout at a high level
      rather than multiple timeouts on low-level operations. ::
  
          @timesout()
          @asyncio.coroutine
          def dostuff(ctxt):
              yield from ctxt.put('msg', 'Working')
              A, B = yield from ctxt.get(['foo', 'bar'])
              yield from ctxt.put('bar', A+B, wait=True)
              yield from ctxt.put('msg', 'Done')
  
          @asyncio.coroutine
          def exec():
              with Context('pva') as ctxt:
                  yield from dostuff(ctxt, timeout=5)