Small speed up to async_listen (#103307)
Avoid constructing an inner function each time we call async_listen and use a partial which holds a reference to the function body with new args instead of making another full function
This commit is contained in:
parent
062b510ec0
commit
dca72c598e
1 changed files with 3 additions and 6 deletions
|
@ -1176,12 +1176,9 @@ class EventBus:
|
|||
self, event_type: str, filterable_job: _FilterableJobType
|
||||
) -> CALLBACK_TYPE:
|
||||
self._listeners.setdefault(event_type, []).append(filterable_job)
|
||||
|
||||
def remove_listener() -> None:
|
||||
"""Remove the listener."""
|
||||
self._async_remove_listener(event_type, filterable_job)
|
||||
|
||||
return remove_listener
|
||||
return functools.partial(
|
||||
self._async_remove_listener, event_type, filterable_job
|
||||
)
|
||||
|
||||
def listen_once(
|
||||
self,
|
||||
|
|
Loading…
Add table
Reference in a new issue