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 hashes)
Built Distribution
Close
Hashes for wcpan.worker-4.2.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a976fc7d371bef735535b6c3e228bfab2f274258a5b17abb999cd0b139881557 |
|
MD5 | cf73e01b638bba118c60cb31dc5d507d |
|
BLAKE2b-256 | 6873c5d3034ba8b2df7253343b1c7ac4b4a7cc863f46158ae227c5c816cd8d25 |