Exscript.util.weakmethod module¶
Weak references to bound and unbound methods.
-
exception
Exscript.util.weakmethod.
DeadMethodCalled
[source]¶ Bases:
exceptions.Exception
Raised by
WeakMethod
if it is called when the referenced object is already dead.
-
class
Exscript.util.weakmethod.
WeakMethod
(name, callback)[source]¶ Bases:
future.types.newobject.newobject
Do not create this class directly; use
ref()
instead.-
callback
¶
-
get_function
()[source]¶ Returns the referenced method/function if it is still alive. Returns None otherwise.
Return type: callable|None Returns: The referenced function if it is still alive.
-
isalive
()[source]¶ Returns True if the referenced function is still alive, False otherwise.
Return type: bool Returns: Whether the referenced function is still alive.
-
name
¶
-
-
Exscript.util.weakmethod.
ref
(function, callback=None)[source]¶ Returns a weak reference to the given method or function. If the callback argument is not None, it is called as soon as the referenced function is garbage deleted.
Parameters: - function (callable) – The function to reference.
- callback (callable) – Called when the function dies.