pydispatch.utils¶
Function checks¶
WeakMethodContainer class¶
- class WeakMethodContainer(other=(), /, **kw)[source]¶
Container to store weak references to callbacks
Instance methods are stored using the underlying function object and the instance id (using
id(obj)) as the key (a two-tuple) and the object itself as the value. This ensures proper weak referencing.Functions are stored using the string “function” and the id of the function as the key (a two-tuple).
- add_method(callback, **kwargs)[source]¶
Add an instance method or function
- Parameters:
callback – The instance method or function to store
Important
Callers using the old
mkeyword must usecallbackinstead.Changed in version 0.3.0: Renamed the
mparameter tocallback.
- del_instance(obj)[source]¶
Remove any stored instance methods that belong to an object
- Parameters:
obj – The instance object to remove
- del_method(callback)[source]¶
Remove an instance method or function if it exists
- Parameters:
callback – The instance method or function to remove
Important
Callers using the old
mkeyword must usecallbackinstead.Changed in version 0.3.0: Renamed the
mparameter tocallback.
InformativeWVDict class¶
- class InformativeWVDict(**kwargs)[source]¶
Bases:
WeakValueDictionaryA WeakValueDictionary providing a callback for deletion
- Keyword Arguments:
del_callback – A callback function that will be called when an item is either deleted or dereferenced. It will be called with the key as the only argument.
EmissionHoldLock class¶
- class EmissionHoldLock(event_instance)[source]¶
Bases:
objectContext manager used for
pydispatch.dispatch.Dispatcher.emission_lock()Supports use as a context manager used in
withstatements and an asynchronous context manager when used inasync withstatements.- Parameters:
event_instance – The
Eventinstance associated with the lock