Skip to main content

BotBoy

Multithreading & processing worker that executes functions and prints the result

Installation

pip install botboy

Usage

Instantiation

from botboy.core import BotBoy

name = 'Adder' # Name of thread/process
task = lambda x, y: x + y # Function to run on separate thread/process
params = [1, 2] # Task arguments
verbose = True # Logging

bot = BotBoy(name=name, task=task, params=params, verbose=verbose)

# You may also instantiate with the setup() method
name = 'Subtracter'
task = lambda x, y: x - y
params = [2, 3]

bot = BotBoy()
bot.setup(name=name, task=task, params=params)

# Print params
print(bot)

# Turn logging on
bot.verbose()

# Turn logging off
bot.silent()

Execute task

result = bot.execute()

# Wait for execution to finish
result = bot.execute(wait=True)

# Execute on separate process
result = bot.execute(is_process=True) # Wait does not work for process

Repeat Task

# Will repeat the assigned task amount of times with an interval inbetween
results = bot.repeat(amt=2, interval=2, wait=True, is_process=False)

Getters

print(bot.name())
print(bot.task())
print(bot.params())
print(bot.result()) # Result will be None unless task was executed

# Or print all params together
print(bot)

Store result in a file or provide a path

# Store result in a file at current directory
bot.save('test.txt')

# Store result at path
import os
bot.save(os.getcwd() + '/test2.txt')

Run multiple tasks with Sequencer

from botboy.core import BotBoy, Sequencer

tasks = [lambda x, y: x + y, lambda x, y: x - y, lambda x, y: x * y]
params = [[1, 2], [3, 4], [5, 6]]

# Create list of BotBoys
bots = Sequencer.pack(tasks=tasks, params=params, verbose=True)

# Instantiate
seq = Sequencer(bots)

# Retrieve results
# Default is false (runs tasks on threads)
# Set to true to run each task on process
results = seq(is_process=False)

Test

Runs the tests on the BotBoy Module

make test-init: Test Initialization
make test-wrapper: Test _wrapper method
make test-client: Test client methods
make test-sequencer: Test Sequencer

Metadata

Release files for botboy 3.0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for botboy 3.0.3
File Size Uploaded Provenance Actions
botboy-3.0.3.tar.gz 5.8 kB Without provenance Details for botboy-3.0.3.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for botboy 3.0.3
File Interpreter ABI Platform Actions
botboy-3.0.3-py2.py3-none-any.whl Python 2, Python 3 none any Details for botboy-3.0.3-py2.py3-none-any.whl

Total release size: 11.6 kB

Release files / botboy-3.0.3.tar.gz

Download URL botboy-3.0.3.tar.gz
Size 5.8 kB
Tags Source
SHA-256 checksum
How to use checksums
a82838afed50b88053961f54f6a2535b6efa98f47b283f786c89d52333180f48
BLAKE2b-256 checksum
How to use checksums
eaf7be3cbf061db3881357f453ffdb130e6e4d8756361ff80301d8e1489e624d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via python-requests/2.31.0

Release files / botboy-3.0.3-py2.py3-none-any.whl

Download URL botboy-3.0.3-py2.py3-none-any.whl
Size 5.9 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
441f34820fb7723ed93d18ed1200e9db441352d1ab410e6229e35ecf7f4f72a1
BLAKE2b-256 checksum
How to use checksums
9cd4c08a5c08579e0779a868ff2136f713101b055a7da5e817b2c34818954d40
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via python-requests/2.31.0

Security for botboy 3.0.3

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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page