upsies.jobs.custom
Custom job that provide the result of a coroutine
Classes
- class upsies.jobs.custom.CustomJob(*, home_directory=None, cache_directory=None, cache_id='', ignore_cache=False, no_output_is_ok=False, hidden=False, autostart=True, guaranteed=False, precondition=None, prejobs=(), callbacks={}, **kwargs)[source]
Bases:
JobBaseWrapper around coroutine function
This job adds the following signals to
signal:indicate_activityEmitted by
indicate_activity(). Registered callbacks get the indicate_activity and text arguments as positional arguments.
- property name
Internal name (e.g. for the cache file name)
- property label
User-facing name
- initialize(*, name, label, worker, catch=())[source]
Set internal state
- Parameters:
name – Name for internal use
label – Name for user-facing use
worker –
Coroutine function that takes the job instance as a positional argument and returns this job’s output
If worker returns any iterable that isn’t a string, each item is passed to
add_output.If worker returns None, it is interpreted as “no output” and the job fails. An empty string is valid output and does not mean the job failed.
catch – Sequence of
Exceptionclasses to catch from worker and pass toerror()
This job finishes when worker returns.
CancelledErrorfrom worker is ignored. Any other exceptions are passed toexception().
- indicate_activity(indicate_activity=None, *, text=None)[source]
Emit the
indicate_activitysignal- Parameters:
indicate_activity – True, False or None (i.e. do not change the current state)
text –
stror None (i.e. do not change the current state)
- async run()[source]
Do the work
This method is called by
start(). Its coroutine is passed toadd_task().Any keyword arguments passed to
initialize()are available viakwargs.The job
is_finishedwhen alladded tasksare done or cancelled. (See alsofinalize()andfinalization().)This method may call
add_task()if more tasks are required.