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

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

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

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for wcpan.worker-3.1.1.tar.gz
Algorithm Hash digest
SHA256 fe7ec05d7d13e69c24ec459676a09cdf24b3a69ed036af8802cd0850b02270f7
MD5 33e117549e0ccc5dc0941a65795937fd
BLAKE2b-256 619c1a7112b0ddf3cb4697b4be0c474c10e55bab159da1f1444ddba65cd5a26a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for wcpan.worker-3.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 c8fa1247d241e411c0c2adabc48a300a2ebe6ff7de80904da4d716948e05a2fa
MD5 f45fa49729ea60f6f0e6abb1896d9ed1
BLAKE2b-256 f1d6bf77abdfc9378aa86096cb874534ed971410e2315602db977cb4e1c2dccc

See more details on using hashes here.

Supported by

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