chancy.utils module¶
- class chancy.utils.TaskManager[source]¶
Bases:
object
A simple task manager that keeps track of tasks.
- chancy.utils.chancy_uuid() str [source]¶
Generate a UUID suitable for use as a job ID.
Note
It’s UUID7, kinda, since the draft keeps changing.
- Returns:
str
- chancy.utils.chunked(iterable, size)[source]¶
Yield chunks of size from iterable.
- Parameters:
iterable – The iterable to chunk.
size – The size of each chunk.
- chancy.utils.import_string(name)[source]¶
Import an object from a string previously created using
importable_name()
.- Parameters:
name – The importable name of the object.
- Returns:
Any
- chancy.utils.importable_name(obj)[source]¶
Get the importable name for an object.
Note
This will only work for objects that are actually importable, i.e. they are defined in a module. Lambdas, for example, will not have an importable name.
- Parameters:
obj – The object to get the importable name for.
- Returns:
str
- chancy.utils.json_dumps(obj, **kwargs)[source]¶
Serialize an object to a JSON formatted str with support for UUIDs.
- Parameters:
obj – The object to serialize.
kwargs – Additional arguments to pass to json.dumps.
- Returns:
str