asynqueue.info.Info(object)
class documentation
Part of asynqueue.info
(View In Hierarchy)
Provides detailed info about function/method calls.
I provide text (picklable) info about a call. Construct me with a
function object and any args and keywords if you want the info to include
that particular function call, or you can set it (and change it) later with
setCall
.
Method | __init__ | Info (remember=False, whichThread=False) |
Method | setCall | Sets my current f-args-kw tuple, returning a reference to myself to allow easy method chaining. |
Method | ID | Returns a unique ID for my current callable. |
Method | forgetID | Use this whenever info won't be needed anymore for the specified call ID, to avoid memory leaks. |
Method | context | Context manager for setting and getting call info. |
Method | getInfo | Provides info about a call. |
Method | saveInfo | Undocumented |
Method | nn | Namespace-name parser. |
Method | aboutCall | Returns an informative string describing my current function call or a previous one identified by ID. |
Method | aboutException | Returns an informative string describing an exception raised from my function call or a previous one identified by ID, or one you supply (as an instance, not a class). |
Method | aboutFailure | Returns an informative string describing a Twisted failure raised from my function call or a previous one identified by ID. You can use this as an errback. |
Method | _divider | Undocumented |
Method | _formatList | Undocumented |
Method | _funcText | Undocumented |
Sets my current f-args-kw tuple, returning a reference to myself to allow easy method chaining.
The function f must be an actual callable object if you want to
use nn
. Otherwise it
can also be a string depicting a callable.
You can specify args with a second argument (as a list or tuple),
and kw with a third argument (as a dict
). If you are
only specifying a single arg, you can just provide it as your second
argument to this method call without wrapping it in a list or tuple. I try
to be flexible.
If you've set a function name and want to add a sequence of args or a dict of keywords, you can do it by supplying the args or kw keywords. You can also set a class instance at that time with the instance keyword.
To sum up, here are the numbers of arguments you can provide:
- A single argument with a callable object or string depicting a callable.
- Two arguments: the callable f plus a single argument or list of arguments to f.
- Three arguments: f, args, and a dict of keywords for the callable.
Parameters | metaArgs | 1-3 arguments as specified above. |
args | A sequence of arguments for the callable f or one previously set. | |
kw | A dict of keywords for the callable f or one previously set. | |
instance | An instance of a class of which the callable f is a method. |
Use this whenever info won't be needed anymore for the specified call ID, to avoid memory leaks.
def context(self, *metaArgs, **kw):
Context manager for setting and getting call info.
Call this context manager method with info about a particular call (same
format as setCall
uses) and
it yields an InfoHolder
object
keyed to that call. It lets you get info about the call inside the context,
without worrying about the ID or calling forgetID
, even
after I have been used for other calls outside the context.
Provides info about a call.
If the supplied name is 'callDict', returns the f-args-kw-instance dict for my current callable. The value of ID is ignored in such case. Otherwise, returns the named information attribute for the previous call identified with the supplied ID.
Parameters | ID | ID of a previous call, ignored if name is 'callDict' |
name | The name of the particular type of info requested. (type: str) | |
nowForget | Set True to remove any reference to this ID or callDict after
the info is obtained. |
Namespace-name parser.
For my current callable or a previous one identified by ID,
returns a 2-tuple suitable for sending to a process worker via
pickle
.
The first element: If the callable is a method, a pickled or fully
qualified name (FQN) version of its parent object. This is
None
if the callable is a standalone function.
The second element: If the callable is a method, the callable's name as
an attribute of the parent object. If it's a standalone function, the
pickled or FQN version. If nothing works, this element will be
None
along with the first one.
Parameters | ID | Previous callable (type: int) |
raw | Set True to return the raw parent (or function) object instead
of a pickle or FQN. All the type checking and round-trip testing still will
be done. |
Returns an informative string describing my current function call or a previous one identified by ID.
Returns an informative string describing an exception raised from my function call or a previous one identified by ID, or one you supply (as an instance, not a class).