Skip to main content

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


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.0.0.tar.gz (3.0 kB view details)

Uploaded Source

Built Distribution

wcpan.worker-4.0.0-py3-none-any.whl (3.9 kB view details)

Uploaded Python 3

File details

Details for the file wcpan.worker-4.0.0.tar.gz.

File metadata

  • Download URL: wcpan.worker-4.0.0.tar.gz
  • Upload date:
  • Size: 3.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for wcpan.worker-4.0.0.tar.gz
Algorithm Hash digest
SHA256 f1abe982bc91e3b2eda3a2e81ab7f9c25489c0de6cb159e01192c52b37bd2e9b
MD5 7eecdd9f82e7adca86f75177846c9854
BLAKE2b-256 248242ad2e13840ab4fbc6499edddd13723b6e7fa16c44edd426b3fd21f5c2e8

See more details on using hashes here.

File details

Details for the file wcpan.worker-4.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for wcpan.worker-4.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6a06581360821c237d8ca89782ee74acef187148b6bdb39e0a7b5e5ac3835328
MD5 3f4c1dbe8cdc5072e61b3b0f8aa2e7bb
BLAKE2b-256 a9bc6df51aab34ad3c3867700ea3bb12b66b832a55fce2670cbea01633427624

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page