Skip to content

decorators.thread

sikvelsigma edited this page Aug 18, 2022 · 7 revisions

Summery

  • decorator repeat_timer

Sets a separate thread that will call a function every set amount of seconds. Returns a Queue-like object that will let you retrieve accumulated results

Contains

repeat_timer

from pyuseful.decorators.thread import repeat_timer

import time

@repeat_timer(timer=1, get_nones=False, get_false=False)
def fun(msg):
    print(msg)
    return 1

a = fun("hi")
time.sleep(2)
print(a.get())
time.sleep(2)
print(a.get())
a.stop()

Clone this wiki locally