Skip to main content

Python utilities classes for safe deployment and management of Threads, synchronization and Python data structures.

Project description

safethread

PyPI License Downloads

safethread is a Python package that wraps common Python data structures in thread-safe classes, providing utilities for thread-safe operations and synchronization mechanisms. It includes custom data structures designed to ensure thread safety when used in multi-threaded programming.

Features

  • Thread-Safe Data Structures: SafeList, SafeDict, SafeTuple, SafeSet, among others.
  • Thread Synchronization: Built-in locking mechanisms to ensure safe operations in multithreaded environments.
  • Threaded Classes: Threaded classes to perform parallel data processing (Pipeline), scheduled function calls (Scheduler), among others.
  • Utility Classes: Additional helpers and utilities for threading, synchronization and other functionality unrelated to multithread programming.

Installation

You can install safethread from PyPI:

pip install safethread

Usage

from safethread.datatype import SafeList, SafeDict
from safethread.thread import Pipeline

# Using SafeList
safe_list = SafeList()
safe_list.append(1)
print(safe_list[0])  # Output: 1

# Using SafeDict
safe_dict = SafeDict()
safe_dict['key'] = 'value'
print(safe_dict['key'])  # Output: 'value'

# Using Pipeline (separate working thread)
pipeline = Pipeline(lambda x: x * 2)
pipeline.start()

# Put some values into the pipeline for processing
pipeline.put(5)
pipeline.put(10)

# Get and print the results
print(f"Processed result 1: {pipeline.get()}")  # Output: 10 (5 * 2)
print(f"Processed result 2: {pipeline.get()}")  # Output: 20 (10 * 2)

# Stop pipeline
pipeline.stop()
pipeline.join()

For further details, check the examples/ folder and the full documentation (link below).

Documentation

The full documentation is available in https://andre-romano.github.io/safethread/docs

Contributing

We welcome contributions! If you'd like to contribute, please fork the repository and submit a pull request.

Special thanks / Acknowledgments

  • PyPi
  • Python 3

License and Copyright

Copyright (C) 2025 - Andre Luiz Romano Madureira

This project is licensed under the Apache License 2.0.

For more details, see the full license text (see LICENSE file).

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

safethread-1.2.0.tar.gz (18.7 kB view details)

Uploaded Source

Built Distribution

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

safethread-1.2.0-py3-none-any.whl (22.5 kB view details)

Uploaded Python 3

File details

Details for the file safethread-1.2.0.tar.gz.

File metadata

  • Download URL: safethread-1.2.0.tar.gz
  • Upload date:
  • Size: 18.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.1

File hashes

Hashes for safethread-1.2.0.tar.gz
Algorithm Hash digest
SHA256 63e37d6d8f1bd4080d3a239b3c7215c549a64cd39c00fead8dbd9e3c50a52191
MD5 156ebcb3b65c8c0d017f9704f7deeb53
BLAKE2b-256 04f7cc009c3367edccac52fada2352988328a8d70a88c22a5a8f2e30a9523120

See more details on using hashes here.

File details

Details for the file safethread-1.2.0-py3-none-any.whl.

File metadata

  • Download URL: safethread-1.2.0-py3-none-any.whl
  • Upload date:
  • Size: 22.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.1

File hashes

Hashes for safethread-1.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 29c99de24b7493436dcf11648bd908b2fe712b49bc5d736fd1c2dafbc8dbb9a5
MD5 b4df3273cfde698bbc013d91d3c31597
BLAKE2b-256 99711478f8f81f83bc0db119fab5439367b0e6360e37819d9e452ad6694f1644

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