GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - meowmeowahr/command_queue: FIFO Queue for Functions

BranchesTags
Open more actions menu

Latest commit

 

History

8 Commits
8 Commits

Folders and files

NameName
Last commit message
Last commit date
src/command_queue
src/command_queue
 
 
.gitignore
.gitignore
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
pyproject.toml
pyproject.toml
 
 
requirements.txt
requirements.txt
 
 

Repository files navigation

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)

About

FIFO Queue for Functions

Topics

commandcommand-queuefifofifo-queuepythonqueue

Resources

Readme
GPL-3.0 license
Activity

Stars

0 stars

Watchers

1 watching

Forks

0 forks
Report repository

Releases

Used by

Contributors

Languages

You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.