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-2.0.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-2.0.0-py3-none-any.whl (5.1 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for wcpan.worker-2.0.0.tar.gz
Algorithm Hash digest
SHA256 fd4559e797927cbbe73b0a8dc9b2bf51b30cc6ad4c19e9598751496cdec05437
MD5 ead827dbf326b985232d2a3746dae35d
BLAKE2b-256 241119726c963597fd22da6b4eb660b79e15a988736e05c09a8f1fc9b9c47996

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for wcpan.worker-2.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4f4e0d3167b34630252d664f95b69707480b47c3067f5c0114c9a9cef113cad8
MD5 8f9b8045ec69b3bd761b94f27bd928ef
BLAKE2b-256 59a39f96931bddf4e4c766e6c4ea9cc6417a6e1dfd894a45ea4098244cb76e9b

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