Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

handler default priority #149

Open
francozappa opened this issue May 27, 2015 · 2 comments
Open

handler default priority #149

francozappa opened this issue May 27, 2015 · 2 comments

Comments

@francozappa
Copy link

When I raise an EventName event _handle_EventName_onetime is called BEFORE _handle_EventName even if the latter it has lower priority:

raiser = EventRaiser()
event_class, event_id = raiser.addListener(EventName, _handle_EventName)  # default priority = 0
event_class, event_id = raiser.addListener(EventName, _handle_EventName_urgent, priority=2)
event_class, event_id = raiser.addListener(EventName, _handle_EventName_onetime, once=True, priority=-1)

It works fine only if I set manually the priority:

event_class, event_id = raiser.addListener(EventName, _handle_EventName, priority=0)
@MurphyMc
Copy link
Collaborator

This is actually an error in the manual. The manual says:

Listeners with no priority set are equivalent to priority 0 – you can use negative priorities to be called after these.

The second part of this is right -- you can use negative priorities to be called after priority zero. The first part is incorrect -- not specifying a priority is not the same as priority zero.

The docstring in the code is actually correct:

priority : The order in which to call event handlers if there are multiple for an event type. Should probably be an integer, where higher means to call it earlier. Do not specify if you don't care.

.. in other words, if you don't specify it, there are no assurances about its order.

Sorry for the confusion.

The POX manual is very likely going to be moving away from where it currently resides in the very near future... I have a local copy which will be the new basis, so I'll leave this issue open so that I remember to update that version.

@MurphyMc
Copy link
Collaborator

While experimental, the current version of POX fangtooth actually does now have 0 as the default priority: MurphyMc/pox@c63eb05

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants