Gevent timer helper
This commit is contained in:
parent
38838b94a2
commit
76af3a2e78
1 changed files with 12 additions and 0 deletions
|
@ -7,6 +7,9 @@ import collections
|
||||||
import time
|
import time
|
||||||
import logging
|
import logging
|
||||||
import base64
|
import base64
|
||||||
|
import gevent
|
||||||
|
|
||||||
|
from Config import config
|
||||||
|
|
||||||
|
|
||||||
def atomicWrite(dest, content, mode="w"):
|
def atomicWrite(dest, content, mode="w"):
|
||||||
|
@ -169,3 +172,12 @@ def httpRequest(url, as_file=False):
|
||||||
return data
|
return data
|
||||||
else:
|
else:
|
||||||
return response
|
return response
|
||||||
|
|
||||||
|
|
||||||
|
def timerCaller(secs, func, *args, **kwargs):
|
||||||
|
gevent.spawn_later(secs, timerCaller, secs, func, *args, **kwargs)
|
||||||
|
func(*args, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
|
def timer(secs, func, *args, **kwargs):
|
||||||
|
gevent.spawn_later(secs, timerCaller, secs, func, *args, **kwargs)
|
||||||
|
|
Loading…
Reference in a new issue