Fix #3226 (unicity of scheduled event names)
Thanks tchiroux for raising the issue and providing the fix as well.
This commit is contained in:
parent
e4696e0471
commit
0c63a4bbda
@ -760,6 +760,9 @@ class XMLStream(asyncio.BaseProtocol):
|
|||||||
:param repeat: Flag indicating if the scheduled event should
|
:param repeat: Flag indicating if the scheduled event should
|
||||||
be reset and repeat after executing.
|
be reset and repeat after executing.
|
||||||
"""
|
"""
|
||||||
|
if name in self.scheduled_events:
|
||||||
|
raise ValueError(
|
||||||
|
"There is already a scheduled event of name: %s" % name)
|
||||||
if seconds is None:
|
if seconds is None:
|
||||||
seconds = RESPONSE_TIMEOUT
|
seconds = RESPONSE_TIMEOUT
|
||||||
cb = functools.partial(callback, *args, **kwargs)
|
cb = functools.partial(callback, *args, **kwargs)
|
||||||
@ -769,7 +772,6 @@ class XMLStream(asyncio.BaseProtocol):
|
|||||||
else:
|
else:
|
||||||
handle = self.loop.call_later(seconds, self._execute_and_unschedule,
|
handle = self.loop.call_later(seconds, self._execute_and_unschedule,
|
||||||
name, cb)
|
name, cb)
|
||||||
|
|
||||||
# Save that handle, so we can just cancel this scheduled event by
|
# Save that handle, so we can just cancel this scheduled event by
|
||||||
# canceling scheduled_events[name]
|
# canceling scheduled_events[name]
|
||||||
self.scheduled_events[name] = handle
|
self.scheduled_events[name] = handle
|
||||||
|
Loading…
x
Reference in New Issue
Block a user