yggdrasil.concurrent.threading.thread_job¶
thread_job ¶
ThreadJob — daemon-thread-backed implementation of AsyncJob.
ThreadJob
dataclass
¶
Bases: AsyncJob[T]
A :class:~yggdrasil.concurrent.job.Job running in a daemon
:class:~threading.Thread, started immediately on construction.
Use :meth:wait to block and retrieve the result::
handle = Job.make(fetch_data, url).fire_and_forget()
# … do other work …
data = handle.wait() # block until thread finishes
data = handle.wait(wait=5.0) # block at most 5 seconds
data = handle.wait(wait=False) # non-blocking poll
result ¶
Return the :class:~yggdrasil.concurrent.job_result.JobResult if done, else None.
wait ¶
Block until the thread finishes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
wait
|
WaitingConfigArg
|
|
None
|
raise_error
|
bool
|
Re-raise the thread's exception when |
True
|
Returns:
| Type | Description |
|---|---|
Optional[T]
|
The job return value, or |
Optional[T]
|
miss (when |
Raises:
| Type | Description |
|---|---|
TimeoutError
|
When a timed wait elapses before the thread finishes. |
BaseException
|
The exception from the job (when |