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-4.2.0.tar.gz
(4.0 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-4.2.0.tar.gz.
File metadata
- Download URL: wcpan.worker-4.2.0.tar.gz
- Upload date:
- Size: 4.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c9acefb8eaf9238f846ab04431865900c60e02e4e0468f244bcd7464f8112491
|
|
| MD5 |
3ad82fd39323fce7851bb2b12a65cd98
|
|
| BLAKE2b-256 |
32929b03d8bb4c5fcbf1e0e368129372e01a716a1ac3193493a384c452ff2613
|
File details
Details for the file wcpan.worker-4.2.0-py3-none-any.whl.
File metadata
- Download URL: wcpan.worker-4.2.0-py3-none-any.whl
- Upload date:
- Size: 5.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a976fc7d371bef735535b6c3e228bfab2f274258a5b17abb999cd0b139881557
|
|
| MD5 |
cf73e01b638bba118c60cb31dc5d507d
|
|
| BLAKE2b-256 |
6873c5d3034ba8b2df7253343b1c7ac4b4a7cc863f46158ae227c5c816cd8d25
|