Menu

#9 global event handler priorities 0.4.8

closed
nobody
None
5
2012-07-26
2011-01-25
Anonymous
No

in Class IRC
def _handle_event(self, connection, event):
"""[Internal]"""
h = self.handlers
for handler in h.get("all_events", []) + h.get(event.eventtype(), []):
if handler1 == "NO MORE":
return

by doing the get for "all_events" first the priority is being ignored. example: the all_events handlers will always be called before the _pingponger even though the pingponger priority is -42...

simple fix is to reverse the order and assume that the all_events will always be lower priority than any single command

or

proper fix is to resort before iterating.

Discussion

  • Ludovic Belliere

    This patch should fix the issue:

    diff --git a/irclib.py b/irclib.py
    index 5f7141c..bed4c1e 100644
    --- a/irclib.py
    +++ b/irclib.py
    @@ -321,7 +321,9 @@ class IRC:
    def _handle_event(self, connection, event):
    """[Internal]"""
    h = self.handlers
    - for handler in h.get("all_events", []) + h.get(event.eventtype(), []):
    + th = h.get("all_events", []) + h.get(event.eventtype(),[])
    + th.sort()
    + for handler in th: #h.get("all_events", []) + h.get(event.eventtype(), []):
    if handler1 == "NO MORE":
    return

     
  • Ludovic Belliere

    Of course, I can't add any file and all the spaces were removed ...

    Well, the idea is to create and sort the list before the 'for' statement.

     
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.