QueuedTask
Bases: Generic[RValue]
Represent a task in the queue.
Attributes:
| Name | Type | Description |
|---|---|---|
entry_id |
int
|
The id of the entry into the queue that contains the task description. |
Source code in src/alchemical_queues/tasks/main.py
262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 | |
done
property
Whether this task has a recorded outcome yet (success or failure).
result returns None both when the task hasn't completed yet and
when it has completed successfully with a return value of None, so
if your task handler's success value can legitimately be None (a
"send this email" task that returns nothing, say), check done
rather than relying on result's truthiness to know whether it's
finished.
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True once |
result
property
Obtain the result of a queued task if it is finished, an exception if the task failed to run, or None if the task has not completed.
This reads whatever was last recorded with
AlchemicalTaskQueue.respond
for this task's entry_id. tasks.Worker always records
{"result": ...} on success or {"error": ..., "error_type": ...}
on failure, which is what lets this property tell those two apart.
If you call respond() yourself with something else entirely (it's
a general queue-level API, not Worker-specific), there's no such
shape to interpret -- you get that data back as-is, same as RValue.
Returns:
| Name | Type | Description |
|---|---|---|
RValue |
Union[RValue, TaskException, None]
|
the value you return from the task handler (or, verbatim,
whatever was passed to |
TaskException |
Union[RValue, TaskException, None]
|
the task failed to execute. |
None |
Union[RValue, TaskException, None]
|
the task has not completed -- but also what you get if the
task completed successfully and returned None itself; see |