mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-30 14:59:34 +01:00
Add support for arguments to addPeriodicEvent callbacks.
This commit is contained in:
parent
97b48abaa2
commit
30c56ae19f
@ -109,11 +109,11 @@ class Schedule(drivers.IrcDriver):
|
|||||||
f = self.removeEvent(name)
|
f = self.removeEvent(name)
|
||||||
self.addEvent(f, t, name=name)
|
self.addEvent(f, t, name=name)
|
||||||
|
|
||||||
def addPeriodicEvent(self, f, t, name=None, now=True):
|
def addPeriodicEvent(self, f, t, name=None, now=True, args=[], kwargs={}):
|
||||||
"""Adds a periodic event that is called every t seconds."""
|
"""Adds a periodic event that is called every t seconds."""
|
||||||
def wrapper():
|
def wrapper():
|
||||||
try:
|
try:
|
||||||
f()
|
f(*args, **kwargs)
|
||||||
finally:
|
finally:
|
||||||
# Even if it raises an exception, let's schedule it.
|
# Even if it raises an exception, let's schedule it.
|
||||||
return self.addEvent(wrapper, time.time() + t, name)
|
return self.addEvent(wrapper, time.time() + t, name)
|
||||||
|
Loading…
Reference in New Issue
Block a user