Skip to main content

An asynchronous task queue with priority support.

Project description

wcpan.worker

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-6.1.1.tar.gz (4.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-6.1.1-py3-none-any.whl (5.2 kB view details)

Uploaded Python 3

File details

Details for the file wcpan_worker-6.1.1.tar.gz.

File metadata

  • Download URL: wcpan_worker-6.1.1.tar.gz
  • Upload date:
  • Size: 4.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.4.0 CPython/3.9.2 Linux/5.15.90.1-microsoft-standard-WSL2

File hashes

Hashes for wcpan_worker-6.1.1.tar.gz
Algorithm Hash digest
SHA256 5906088295b68820a57e55940a19df4bd94d39571a8a49ecde44c6ab133e5883
MD5 f0d5e774192de76cd7e8f2e7806a6f0f
BLAKE2b-256 7adbead47b139c91da26e3c9b919c88560701b2166eb7e3cf424e652726d753c

See more details on using hashes here.

File details

Details for the file wcpan_worker-6.1.1-py3-none-any.whl.

File metadata

  • Download URL: wcpan_worker-6.1.1-py3-none-any.whl
  • Upload date:
  • Size: 5.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.4.0 CPython/3.9.2 Linux/5.15.90.1-microsoft-standard-WSL2

File hashes

Hashes for wcpan_worker-6.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 e741292595f258cf8e5bf84f80efb518633145202bd8c4c6c8a80f2b9255ab0c
MD5 1be54b4b5d7ca301ecdba28fb8e2f448
BLAKE2b-256 aa8c9a5abe659b2fdd17a2e1d540495d3e5c06dfb3c10578fac40c680738d2c6

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