From 0c63a4bbdafcb557430e02f774dc88c5f2a974c1 Mon Sep 17 00:00:00 2001 From: mathieui Date: Fri, 30 Sep 2016 20:59:31 +0200 Subject: [PATCH] Fix #3226 (unicity of scheduled event names) Thanks tchiroux for raising the issue and providing the fix as well. --- slixmpp/xmlstream/xmlstream.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/slixmpp/xmlstream/xmlstream.py b/slixmpp/xmlstream/xmlstream.py index 686dfde8..c491746d 100644 --- a/slixmpp/xmlstream/xmlstream.py +++ b/slixmpp/xmlstream/xmlstream.py @@ -760,6 +760,9 @@ class XMLStream(asyncio.BaseProtocol): :param repeat: Flag indicating if the scheduled event should 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: seconds = RESPONSE_TIMEOUT cb = functools.partial(callback, *args, **kwargs) @@ -769,7 +772,6 @@ class XMLStream(asyncio.BaseProtocol): else: handle = self.loop.call_later(seconds, self._execute_and_unschedule, name, cb) - # Save that handle, so we can just cancel this scheduled event by # canceling scheduled_events[name] self.scheduled_events[name] = handle