This document describes the current stable version of Celery (3.1). For development docs,
go here.
celery.utils.dispatch.saferef
“Safe weakrefs”, originally from pyDispatcher.
Provides a way to safely weakref any function, including bound methods (which
aren’t handled by the core weakref module).
-
celery.utils.dispatch.saferef.safe_ref(target, on_delete=None)[source]
Return a safe weak reference to a callable target
Parameters: |
- target – the object to be weakly referenced, if it’s a
bound method reference, will create a BoundMethodWeakref,
otherwise creates a simple weakref.ref.
- on_delete – if provided, will have a hard reference stored
to the callable to be called after the safe reference
goes out of scope with the reference object, (either a
weakref.ref or a BoundMethodWeakref) as argument.
|