Skip to main content

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()

Metadata

Release files for wcpan-worker 4.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for wcpan-worker 4.0.0
File Size Uploaded
wcpan.worker-4.0.0.tar.gz 3.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for wcpan-worker 4.0.0
File Interpreter ABI Platform
wcpan.worker-4.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 6.9 kB

Release files / wcpan.worker-4.0.0.tar.gz

Download URL wcpan.worker-4.0.0.tar.gz
Size 3.0 kB
Tags Source
SHA-256 checksum
How to use checksums
f1abe982bc91e3b2eda3a2e81ab7f9c25489c0de6cb159e01192c52b37bd2e9b
BLAKE2b-256 checksum
How to use checksums
248242ad2e13840ab4fbc6499edddd13723b6e7fa16c44edd426b3fd21f5c2e8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / wcpan.worker-4.0.0-py3-none-any.whl

Download URL wcpan.worker-4.0.0-py3-none-any.whl
Size 3.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6a06581360821c237d8ca89782ee74acef187148b6bdb39e0a7b5e5ac3835328
BLAKE2b-256 checksum
How to use checksums
a9bc6df51aab34ad3c3867700ea3bb12b66b832a55fce2670cbea01633427624
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page