Skip to main content

Subprocess-based task queue.

Project description

SoonQ

A subprocess-based task queue.

Introduction

SoonQ implements a simple FIFO queue using SQLite. It was created primarily for running long simulations.

As of yet, the vision of a subprocess-based workflow has not been realized. However, the package still works as a task queue.

Installation

pip install soonq

Usage

Users must create their own subclass of soonq.BaseTask. Subclasses must define a run() method, which contains the business logic for the task (what we care about). At least for now, input arguments to this method are restricted to being JSON serializable.

Running the examples

Example files are included in the examples directory. Clone SoonQ in your desired location...

C:\desired\location>git clone https://github.com/n8jhj/SoonQ.git

...and then navigate into the SoonQ directory and install it. Be careful to include the dot!

pip install .

Now run the following in two separate terminals:

Terminal 1:

Run the same script a couple times.

C:\...\SoonQ>python -m examples timer_task
Queued task: 913d56e9-a609-4b84-b937-479a94716527

C:\...\SoonQ>python -m examples timer_task
Queued task: da952424-98d9-42e1-8851-91a30924b94b

C:\...\SoonQ>

Terminal 2:

C:\...\SoonQ>python -m examples timer_worker
Running task: 913d56e9-a609-4b84-b937-479a94716527
1/3 Sleeping 3 seconds...
2/3 Sleeping 3 seconds...
3/3 Sleeping 3 seconds...
Slept 9 seconds total.
Finished task: 913d56e9-a609-4b84-b937-479a94716527

Running task: da952424-98d9-42e1-8851-91a30924b94b
1/3 Sleeping 3 seconds...
2/3 Sleeping 3 seconds...
3/3 Sleeping 3 seconds...
Slept 9 seconds total.
Finished task: da952424-98d9-42e1-8851-91a30924b94b

Waiting for next task... (Ctrl + C to quit)

With the worker running, more tasks can be enqueued and will be immediately processed.

Press Ctrl + C to quit the worker.

Quitting

C:\...\SoonQ>

Etymology

This project is named after my friend Soon-Kyoo, with whom I enjoyed countless bouts of epic ping-pong in college. People call him Q, for short.

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

SoonQ-0.2.0.tar.gz (8.3 kB view details)

Uploaded Source

Built Distribution

SoonQ-0.2.0-py3-none-any.whl (8.7 kB view details)

Uploaded Python 3

File details

Details for the file SoonQ-0.2.0.tar.gz.

File metadata

  • Download URL: SoonQ-0.2.0.tar.gz
  • Upload date:
  • Size: 8.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.0.10 CPython/3.8.2 Windows/10

File hashes

Hashes for SoonQ-0.2.0.tar.gz
Algorithm Hash digest
SHA256 85d469277a413b3def03a589b683a6099bd286d5ebe79763a27a009174e2988f
MD5 65562d84367c171b1b407f42abc59089
BLAKE2b-256 d8ad3b9f8bc9f10a8dfcac3d9906bda66b4164e5cc35cc6cd574cc5848590b1a

See more details on using hashes here.

File details

Details for the file SoonQ-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: SoonQ-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 8.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.0.10 CPython/3.8.2 Windows/10

File hashes

Hashes for SoonQ-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a9d57676b2aec765c581e85f7d22ef02e8e5499f4dbdfdf076c20a76bca53ae3
MD5 a7902b46f9937b30c6e94880bb3eed0c
BLAKE2b-256 d73711fafbb2fb640f85835bf41282cc70f4a0b07af53da302497ca838f76750

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page