Skip to main content

A Python library to maximise CPU usage by smartly sharing threads among multiple functions.

Project description

ThreadShare


ThreadShare Logo


A Python library to maximise CPU usage by smartly sharing threads among multiple functions.

Why ThreadShare ?

Systems with a limited number of cores, like the Raspberry Pi, struggle with CPU resource constraints, making it challenging to efficiently execute multiple tasks functions.

ThreadShare is an Python library designed to efficiently utilize a single CPU core by dynamically sharing threads among multiple functions. It adapts to the execution rates and computational loads of tasks to ensure optimal performance.

Key Features

  • Thread Loop Sharing: Run multiple functions at different rates on shared threads.
  • Dynamic Thread Management: Automatically manages thread creation and load balancing. Adaptive Load Balancing: Dynamically allocate tasks to threads based on their load.
  • Rate-Based Task Scheduling: Schedules tasks based on their execution rates.
  • Resource Monitoring: Monitors CPU and memory usage to adaptively manage thread utilization.
  • Graceful Shutdown: Ensures all tasks are completed before shutting down.

Installation

To install ThreadShare, you can use pip:

pip install ThreadShare

Usage

Here is a basic example to demonstrate how to use ThreadShare:

from ThreadShare import ThreadManager

# Define your function
def example_task():
    print("Task executed.")

# Initialize ThreadManager
manager = ThreadManager()

# Add tasks
manager.add_task(example_task, rate=0.2)

# Shutdown (optional)
manager.shutdown()

Metrics and Monitoring

ThreadShare provides real-time metrics and resource monitoring. These metrics can be accessed programmatically for advanced use-cases or can be logged for monitoring and debugging.

License

This project is licensed under the MIT License - see the LICENSE.md file for details.

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

ThreadShare-0.2.tar.gz (4.3 kB view details)

Uploaded Source

Built Distribution

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

ThreadShare-0.2-py3-none-any.whl (5.1 kB view details)

Uploaded Python 3

File details

Details for the file ThreadShare-0.2.tar.gz.

File metadata

  • Download URL: ThreadShare-0.2.tar.gz
  • Upload date:
  • Size: 4.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.13

File hashes

Hashes for ThreadShare-0.2.tar.gz
Algorithm Hash digest
SHA256 fbdcb481359c58a9baa033161bbc2853aebdccaf0ac86febe51f4b9dae8c1cf0
MD5 065d7aa51225c2af9819ed78857ad10d
BLAKE2b-256 c760ae75fd913fc8c51f51b9c9116e0d72de92b955ac816dde5a198d49be8e2b

See more details on using hashes here.

File details

Details for the file ThreadShare-0.2-py3-none-any.whl.

File metadata

  • Download URL: ThreadShare-0.2-py3-none-any.whl
  • Upload date:
  • Size: 5.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.13

File hashes

Hashes for ThreadShare-0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 b17dd461cbbdd78e889390e07dc62b5ba079103e0020a5ddf2de30b8aa6037e2
MD5 92d670ed35a2a3f60ca90a365ec2823d
BLAKE2b-256 574302832d7cb945d12cc2962a25664a68b1c1af6d7d4ba0eae3547b1688fabd

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