Skip to content

Latest commit

 

History

History
22 lines (17 loc) · 443 Bytes

File metadata and controls

22 lines (17 loc) · 443 Bytes
title type language tags cover dateModified
Delayed function execution
snippet
python
function
succulent-10
2020-11-02

Invokes the provided function after ms milliseconds.

  • Use time.sleep() to delay the execution of fn by ms / 1000 seconds.
from time import sleep

def delay(fn, ms, *args):
  sleep(ms / 1000)
  return fn(*args)

delay(lambda x: print(x), 1000, 'later') # prints 'later' after one second