An asynchronous task queue with priority support.
Project description
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
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-2.0.0.dev1.tar.gz.
File metadata
- Download URL: wcpan.worker-2.0.0.dev1.tar.gz
- Upload date:
- Size: 3.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1b4136950b41aedf6376fca21513fbfbb3478a1253ba4ba492d85979ee7a9fff
|
|
| MD5 |
58045faec19ccce2e17db6b67c065731
|
|
| BLAKE2b-256 |
693fe3f2bfe82c4eedb9418db1cce3e346b7f5db007d80ebc7df18fdc203439d
|
File details
Details for the file wcpan.worker-2.0.0.dev1-py3-none-any.whl.
File metadata
- Download URL: wcpan.worker-2.0.0.dev1-py3-none-any.whl
- Upload date:
- Size: 5.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5d6d6d22de8357e96893c0c2aeb4c09087ca1e2ce0734cacc1f20e251ed6c595
|
|
| MD5 |
a7958a08003f98ba949338c8e5b3e3ef
|
|
| BLAKE2b-256 |
bb26216bb9a2bd1ec1a76da7b9de8a73972626e1c86dbfd0de398977e2478cd6
|