Skip to main content

A Python library with advanced system tools.

Project description

Boa

A library of advanced system tools for Python.

Boa adds upgraded versions of system tools. For example, this includes advanced pipes, parallelism, etc. It is designed to have a simple Pythonic interface.

To list all of the available packages, simply Python's interactive prompt and explore:

>>> from Boa import *
>>> help(parallel)
Help on package Boa.parallel in Boa:

NAME
    Boa.parallel - This package contains some useful tools when working with multithreading or multiprocessing.

PACKAGE CONTENTS
    abc (package)
    exceptions
    process (package)
    thread (package)
...

Some practical examples of the content of Boa include:

  • Futures to manage eventual objects to come:
>>> from Boa.parallel.thread import Future
>>> from threading import Thread
>>> f = Future()
>>> def show_future():
...         while True:
...                 print(f"Future got set to {f.result()}.")
...                 f.clear()
... 
>>> Thread(target = show_future).start()
>>> f.set("Hello")
Future got set to Hello.
>>> f.set(True)
Future got set to True.
>>> f.set_exception(ValueError("Time to stop"))
Exception in thread Thread-1 (show_future):
Traceback (most recent call last):
  File "C:\Program Files\Python311\Lib\threading.py", line 1038, in _bootstrap_inner
     self.run()
  File "C:\Program Files\Python311\Lib\threading.py", line 975, in run
    self._target(*self._args, **self._kwargs)
  File "<stdin>", line 3, in show_future
  File "C:\Users\Vince\OneDrive\Documents\Python\Boa\Boa\parallel\thread\future.py", line 248, in result
    raise self.__exception from None
ValueError: Time to stop

Futures are particularly useful in multithreaded environement for synchronization, especially with their special methods to cancel Futures, link them together, etc.

  • Many parallelism decorators:
>>> from Boa.parallel.thread import exclusive
>>> from time import sleep
>>> @exclusive
... def run():
...         print("Entering...")
...         sleep(5)
...         print("Exiting.")
... 
>>> from threading import Thread
>>> for i in range(5):
...         Thread(target = run).start()
... 
Entering...
>>> Exiting.
Entering...
Exiting.
Entering...
Exiting.
Entering...
Exiting.
Entering...
Exiting.

This decorator and others allow you to ensure exclusion with precise rules accros a multithreaded program.

  • Better signal handling:
>>> from Boa.signal import *
>>> Signals.
Signals.SIGABRT           Signals.SIGILL            Signals.SIGTERM           Signals.bit_length(       Signals.from_bytes(       Signals.numerator
Signals.SIGBREAK          Signals.SIGINT            Signals.as_integer_ratio( Signals.conjugate(        Signals.imag              Signals.real
Signals.SIGFPE            Signals.SIGSEGV           Signals.bit_count(        Signals.denominator       Signals.mro()             Signals.to_bytes(
>>> Signals.SIGINT.add_handler(lambda s : print(f"Received signal {s.name}"))
>>> Received signal SIGINT

KeyboardInterrupt
  • And many other useful random features!

Note that this library is extensively documented. Use Python's help system (for example the help function while in an interactive interpreter) to learn how to use all the modules and classes.

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

boa_lib-1.4.tar.gz (45.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

boa_lib-1.4-py2.py3-none-any.whl (57.6 kB view details)

Uploaded Python 2Python 3

File details

Details for the file boa_lib-1.4.tar.gz.

File metadata

  • Download URL: boa_lib-1.4.tar.gz
  • Upload date:
  • Size: 45.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.2

File hashes

Hashes for boa_lib-1.4.tar.gz
Algorithm Hash digest
SHA256 818573c1d64ac4a7aed462bb4c359ee60c04a3cdd8c6389c0cc3b05143e6f9d3
MD5 c364edab130292b3944b5dadd0768d07
BLAKE2b-256 d21cf73cb2c4a00f27e4bf6de260d42169939fa737c93492e7f791edf2dfc372

See more details on using hashes here.

File details

Details for the file boa_lib-1.4-py2.py3-none-any.whl.

File metadata

  • Download URL: boa_lib-1.4-py2.py3-none-any.whl
  • Upload date:
  • Size: 57.6 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.2

File hashes

Hashes for boa_lib-1.4-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 959b80cb79eeb642339382b634b0d5f4a79ee032259d39e9aae0e7be42aa3c8c
MD5 f527dcae2f3979fb18fa7888b93ac863
BLAKE2b-256 9d905aea6612b7c275628d6e5a22a8861c48e8d9e614ff44b4fb1a7cf269bb1c

See more details on using hashes here.

Supported by

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