def with_timeout(seconds, function, *args, **kwds):
 timeout_value = kwds.pop('timeout_value', _NONE)
 timeout = Timeout.start_new(seconds)
 try:
  return function(*args, **kwds)
 except Timeout:
  if ((sys.exc_info()[1] is timeout) and (timeout_value is not _NONE)):
   return timeout_value
  raise
 finally:
  timeout.cancel()

def with_timeout ( seconds , function , * args , ** kwds ) : timeout_value = kwds . pop ( 'timeout_value' , _NONE ) timeout = Timeout . start_new ( seconds ) try : return function ( * args , ** kwds ) except Timeout : if ( ( sys . exc_info ( ) [ 1 ] is timeout ) and ( timeout_value is not _NONE ) ) : return timeout_value raise finally : timeout . cancel ( )
wraps a .