mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-12-25 04:02:46 +01:00
Robustitude\!
This commit is contained in:
parent
77458078e9
commit
e45ad03ef4
@ -90,8 +90,11 @@ class Schedule(drivers.IrcDriver):
|
|||||||
def addPeriodicEvent(self, f, t, name=None):
|
def addPeriodicEvent(self, f, t, name=None):
|
||||||
"""Adds a periodic event that is called every t seconds."""
|
"""Adds a periodic event that is called every t seconds."""
|
||||||
def wrapper():
|
def wrapper():
|
||||||
f()
|
try:
|
||||||
return self.addEvent(wrapper, time.time() + t, name)
|
f()
|
||||||
|
finally:
|
||||||
|
# Even if it raises an exception, let's schedule it.
|
||||||
|
return self.addEvent(wrapper, time.time() + t, name)
|
||||||
return wrapper()
|
return wrapper()
|
||||||
|
|
||||||
removePeriodicEvent = removeEvent
|
removePeriodicEvent = removeEvent
|
||||||
@ -103,7 +106,10 @@ class Schedule(drivers.IrcDriver):
|
|||||||
(t, name) = heapq.heappop(self.schedule)
|
(t, name) = heapq.heappop(self.schedule)
|
||||||
f = self.events[name]
|
f = self.events[name]
|
||||||
del self.events[name]
|
del self.events[name]
|
||||||
f()
|
try:
|
||||||
|
f()
|
||||||
|
except Exception, e:
|
||||||
|
log.exception('Uncaught exception in scheduled function:')
|
||||||
|
|
||||||
try:
|
try:
|
||||||
ignore(schedule)
|
ignore(schedule)
|
||||||
|
Loading…
Reference in New Issue
Block a user