Skip to main content

A Python-based batch queue manager

Project description

batch_queue2

batch_queue2 is a simple task queuing system built using Python's asyncio. It allows you to submit, manage, and track tasks using a lightweight, XML-RPC-based interface.

Features

  • Submit, list, suspend, resume, and kill tasks using command-line commands.
  • Tasks can be queued, paused, or resumed based on available CPUs.
  • XML-RPC server for managing task requests.
  • Ability to run tasks using multiple CPUs.
  • Tasks can be paused and resumed.

Requirements

  • Python 3.7+
  • aiohttp
  • requests

Installation

You can install batch_queue2 from PyPI:

pip install batch_queue2

Or clone the repository from Sourcehut:

git clone https://sr.ht/~ndbecker2/batch_queue2/
cd batch_queue2
python -m pip install .

Usage

After installing, you can use the batch_queue command to manage tasks. Below are the available options:

Starting the Server

To start the server:

batch_queue start --max-cpus 4
  • --max-cpus: (Optional) Specify the maximum number of CPUs to use. Defaults to the number of CPUs available on your system.

The server will start in daemon mode by default.

Submitting a Task

To submit a task, use the submit command:

batch_queue submit <command>

For example:

batch_queue submit sleep 10

You can also optionally specify:

  • --log-stdout <file>: Redirect the standard output of the task to a file.
  • --log-stderr <file>: Redirect the standard error of the task to a file.

Listing Tasks

To list all tasks:

batch_queue list

This will display:

  • Max CPUs available.
  • Active tasks.
  • Queued tasks.
  • Paused tasks.

Suspending and Resuming Tasks

To suspend a running task:

batch_queue suspend <task_id>

To resume a paused task:

batch_queue resume <task_id>

Killing a Task

To kill a specific task:

batch_queue kill <task_id>

You can also optionally specify the signal to use, default is SIGTERM.

Getting Task Information

To get detailed information about a specific task:

batch_queue id <task_id>

This command provides detailed information about the task including command, user, working directory, environment variables, and logs.

Stopping the Server

To stop the server:

batch_queue stop

This command gracefully stops the server, ensuring no tasks are left in a zombie state.

Example Workflow

  1. Start the server using:

    batch_queue start --max-cpus 4
    
  2. Submit a couple of tasks:

    batch_queue submit sleep 10
    batch_queue submit echo "Hello World"
    
  3. List the tasks to see the active, queued, and paused tasks:

    batch_queue list
    
  4. Suspend a running task:

    batch_queue suspend 0
    
  5. Resume a paused task:

    batch_queue resume 0
    
  6. Stop the server:

    batch_queue stop
    

Logging

The server logs all activity to ~/batch_queue.log. You can view the log to monitor task submissions, task status changes, server starts and stops, etc.

License

This project is licensed under the MIT License. See the LICENSE file for more details.

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

batch_queue2-1.0.4.tar.gz (7.7 kB view details)

Uploaded Source

Built Distribution

batch_queue2-1.0.4-py3-none-any.whl (8.2 kB view details)

Uploaded Python 3

File details

Details for the file batch_queue2-1.0.4.tar.gz.

File metadata

  • Download URL: batch_queue2-1.0.4.tar.gz
  • Upload date:
  • Size: 7.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.13.0

File hashes

Hashes for batch_queue2-1.0.4.tar.gz
Algorithm Hash digest
SHA256 de2a68a10f6ad666dc937f8fe934712cd78cf3464e358ff90205b078f1eaba64
MD5 b6d3f03f86b575f2f05c3a07209d38b3
BLAKE2b-256 d5a5956fb20d6b28d46ce12c0680d8126fc3bc0714dbc6987cb806cb2be81345

See more details on using hashes here.

File details

Details for the file batch_queue2-1.0.4-py3-none-any.whl.

File metadata

File hashes

Hashes for batch_queue2-1.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 c8aba0ccbc36496079ea361204b16d5eba2e6f6fa80a0142fb93c05a3937a8dc
MD5 1b2d0b3376203d485149b7835356bac4
BLAKE2b-256 5570e7bd5837a074a219460da07002a114a370a6fcc0c7c0c46083197c5e4b82

See more details on using hashes here.

Supported by

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