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

Uploaded Python 3

File details

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

File metadata

  • Download URL: wcpan_worker-6.0.0.tar.gz
  • Upload date:
  • Size: 3.9 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.0.0.tar.gz
Algorithm Hash digest
SHA256 1e434523fd2883943e8b419250017d3b5627c055ef90a994a06d95bdc82b3607
MD5 a31bc238560701359f529e1cb1f2b249
BLAKE2b-256 ef22521c43c7adbdb34994a59b5a5d524fe9429fad73778dc2b04cd3c3bb7f40

See more details on using hashes here.

File details

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

File metadata

  • Download URL: wcpan_worker-6.0.0-py3-none-any.whl
  • Upload date:
  • Size: 5.1 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.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1e9edd8cb018139961760ee5bce3e38eb44689fbba59e78a5c60f27a567a1cb1
MD5 e77fe15d3aa60e3c78ad2519b309d336
BLAKE2b-256 b43ac9ccf3f49ab3fcfb18463a7722e1c194ef40cdf1f12d30057309995a9565

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