An asynchronous task queue with priority support.
Project description
wcpan.worker
An asynchronous task queue with priority support.
from wcpan.worker import AsyncQueue, Task
class HighPriorityTask(Task):
@property
def priority(self) -> int:
return 2
class LowPriorityTask(Task):
@property
def priority(self) -> int:
return 1
# Note this queue is non-preemptive.
queue = AsyncQueue()
queue.start()
# function_2 will come first.
queue.post(LowPriorityTask(function_1))
queue.post(HighPriorityTask(function_2))
# cancel pending tasks
queue.flush()
# wait for executing task (if any) ends, then stop the queue
await queue.stop()
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
wcpan.worker-5.0.0.tar.gz
(4.1 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file wcpan.worker-5.0.0.tar.gz.
File metadata
- Download URL: wcpan.worker-5.0.0.tar.gz
- Upload date:
- Size: 4.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.8.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a6fe6f13ac14e2400e5972db21704d6e912ff0cb4a9d0d25e105b0f696445c33
|
|
| MD5 |
8ec6bdf71dd0cbb43476f854c56842ef
|
|
| BLAKE2b-256 |
38fdb270a3ede26f3900fbcb974787f7991134533e810afac1b65308697b14e7
|
File details
Details for the file wcpan.worker-5.0.0-py3-none-any.whl.
File metadata
- Download URL: wcpan.worker-5.0.0-py3-none-any.whl
- Upload date:
- Size: 5.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.8.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
24d74f1a2e30b3bbd55bb044435c71c76c4a004116f2e8345c5e1490e36ed4e8
|
|
| MD5 |
16dd697afb3c667a1efd025ec51b7a0c
|
|
| BLAKE2b-256 |
d7b76a83b5f3bdb8439f8ef770a797cb281ad2483eb4118717ed4e565c2c9092
|