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

Uploaded Python 3

File details

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

File metadata

  • Download URL: wcpan.worker-4.1.1.tar.gz
  • Upload date:
  • Size: 3.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.21.0 setuptools/39.0.1 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.0

File hashes

Hashes for wcpan.worker-4.1.1.tar.gz
Algorithm Hash digest
SHA256 04f2869cb75b1fd56d0c9e88fe332f98862c4c7a1fd695403a9688e62873cf79
MD5 93a8e8ca6d397f740f37afbb1973704d
BLAKE2b-256 a798e5590f83a6909510b37263569f85232ccdfcc4bcf48e8c653ebb58d7d8c2

See more details on using hashes here.

File details

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

File metadata

  • Download URL: wcpan.worker-4.1.1-py3-none-any.whl
  • Upload date:
  • Size: 4.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.21.0 setuptools/39.0.1 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.0

File hashes

Hashes for wcpan.worker-4.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 410e0270f299f2fc51b641ca7d8fc8731041f52fd955e5a4316bb5be6890512a
MD5 447ebd0dee74e9ddd25354e2ba5af152
BLAKE2b-256 791c36105a130dfe7946a36c354f9108580a2e6f24c781430fa4192e1ebbbbc2

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