Multithreading & processing worker that executes functions and prints the result
Project description
BotBoy
Multithreading & processing worker that executes functions and prints the result
Installation
pip install botboy
Usage
Create a new BotBoy object with a pre-defined function object and a name
from botboy import BotBoy
bot = BotBoy('Adder', lambda x, y: x + y)
Display the information
bot.display_information()
> Adder
> <function <lambda> at 0x10e6e8040>
Set new task to run
bot.set_task(lambda x, y: x - y)
Execute function object on separate thread
bot.execute(1, 2)
> Adder is executing task: <function <lambda> at 0x10e6e8040>
> Retrieved result from Adder: 3
Execute function object on separate process
bot.set_processing() # Can be turned back to thread by running same method
bot.execute(3, 4)
> Adder is executing task: <function <lambda> at 0x10e6e8040>
> Retrieved result from Adder: 7
Store result in file result.txt
bot.set_on_file() # Can be turned back to off by running same method
bot.execute(7, 8)
> Adder is executing task: <function <lambda> at 0x10a1e2040>
> Retrieved result from Adder: 15
> Storing result in file: result.txt
Pause execution for threads and wait for result
bot.set_wait() # Can be turned back to off by running same method
bot.execute(100, 10000)
> Waiting for <function <lambda> at 0x109f023b0> to finish
> Adder is executing task: <function <lambda> at 0x109f023b0>
> Retrieved result from Adder: 10100
Get result manually
bot.set_wait()
bot.execute(1, 2)
if bot.get_result(): print(bot.get_result())
> Waiting for <function <lambda> at 0x10592e3b0> to finish
> Adder is executing task: <function <lambda> at 0x10592e3b0>
> Retrieved result from Adder: 3
> 3
Test
Runs the tests on the BotBoy module
make test
or
python3 test
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
botboy-1.4.0.tar.gz
(4.0 kB
view hashes)
Built Distribution
Close
Hashes for botboy-1.4.0-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6a9ab60a877784a8dd2190ac2aa7e4e6f2e620a6bdc2927f102adb0346333781 |
|
MD5 | 208acfd30924be5eb84707c9531b75fa |
|
BLAKE2b-256 | 7f08e59bdb4700f6fe4c2348b564df14ef5e0b4ec1bb55d54a9dbcc922fe3b6c |