A Command Queue for Python
Run commands (which can be regular functions) in a FIFO queue. Can be run in a background thread.
Usage examples
Simple filling and running of the queue
from command_queue import CommandQueue
from command_queue.commands import FunctionCommand
import functools
example_queue = CommandQueue()
# Add example commands
for i in range(100):
example_queue.add_command(
FunctionCommand(functools.partial(print, f"Running loop iteration {i}"))
)
# Attempt to run command queue at 60 commands per second
# Stop running once queue empties
example_queue.spin(60, until_empty=True)
Example of ParallelCommandGroups
from command_queue import CommandQueue
from command_queue.commands import FunctionCommand, ParallelCommandGroup
import functools
import time
def do_something():
print(f"Something happended on {time.time()}")
time.sleep(0.05)
def do_something_2():
print(f"Something_2 happended on {time.time()}")
time.sleep(0.05)
example_queue = CommandQueue()
# Add example non-parallel commands
# These commands will run sequentially
for i in range(2):
example_queue.add_command(FunctionCommand(functools.partial(do_something)))
# These commands will run at the same time using threads
# Add example parallel command
# These commands will run at the same time
example_queue.add_command(
ParallelCommandGroup(
FunctionCommand(functools.partial(do_something_2)),
FunctionCommand(functools.partial(do_something_2)),
FunctionCommand(functools.partial(do_something_2)),
FunctionCommand(functools.partial(do_something_2)),
FunctionCommand(functools.partial(do_something_2)),
FunctionCommand(functools.partial(do_something_2)),
)
)
# Attempt to run command queue at 10 commands per second
# Stop running once queue empties
example_queue.spin(10, until_empty=True)
Metadata
Release files for command-queue 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| command_queue-0.2.0.tar.gz | 16.5 kB | Without provenance | Details for command_queue-0.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| command_queue-0.2.0-py3-none-any.whl | Python 3 | none | any | Details for command_queue-0.2.0-py3-none-any.whl |
Total release size: 32.3 kB
Release files / command_queue-0.2.0.tar.gz
| Download URL | command_queue-0.2.0.tar.gz |
|---|---|
| Size | 16.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8a14c4466e72f1f58b27d40c80fd177432565ae7eb0913fc2d2c30ac2b145f6a
|
|
BLAKE2b-256 checksum How to use checksums |
46d326ab06e02c9746983863abbd9ee624d0b839d706c12b8ed55dd3e56ea242
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.12.4
|
Release files / command_queue-0.2.0-py3-none-any.whl
| Download URL | command_queue-0.2.0-py3-none-any.whl |
|---|---|
| Size | 15.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
fb7e3ab177a0701dceca454f1a9f81d0fae2c8c3f7eb1170f4fd5f7ee68fea73
|
|
BLAKE2b-256 checksum How to use checksums |
51b9d45693d46723cb6d0e0bfdc75b0fb4cc75de69d36e45eecf692d0b4f7e55
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.12.4
|
Security for command-queue 0.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.