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.1.0.tar.gz (3.1 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-4.1.0-py3-none-any.whl (3.9 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for wcpan.worker-4.1.0.tar.gz
Algorithm Hash digest
SHA256 a78e4649416461f716bced698e0ae2f9c525abbc53fb83a37e26b2f8a9afb461
MD5 5b6882d6503f865ac1b710055b28c34b
BLAKE2b-256 86368a9967f85481296dc99cf900998dc275e18f640deda1e78e56acb16ed32a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for wcpan.worker-4.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f9495056935e3d5f6d83188a474dd64f1222217944d06552307d2cc8eee26659
MD5 4697978850a398f37c7ccb55efc8c24a
BLAKE2b-256 d696f8c841ebdba8191a221675833fb5d42cad0737519e9726d13cad3c72f929

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