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.0.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.0-py3-none-any.whl (3.9 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for wcpan.worker-3.1.0.tar.gz
Algorithm Hash digest
SHA256 48dec9db7825bc7c269f532894f2633c0afed5a45c6b47e3ee29177661973cec
MD5 670f9ef67653720f9cdd7277da53788c
BLAKE2b-256 1a6d98e169d7218da27662664da6f593327ab87200226122696c8a2d95e6fd31

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for wcpan.worker-3.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 aa009936ee965bf5f3191d6c1e1c755fc94a7968c86a19bc3a04a1838743b5cb
MD5 8f97e0608ca04785dc18b5b3e80acf4b
BLAKE2b-256 60954f0ceae68e8523b0db502b720d870cabed123cebca63e8407649dfda2cf8

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