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, scheduled function calls, among others.
  • Utility Classes and Functions: Additional helpers and utilities for threading (Pipeline, PipelineStage, Publish/Subscribe, etc), 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.utils import PipelineStage

# 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)
stage = PipelineStage(lambda x: x * 2)
stage.start()

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

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

# Stop pipeline
stage.stop()
stage.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

  • pdocs
  • 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.3.1.tar.gz (20.2 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.3.1-py3-none-any.whl (25.2 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for safethread-1.3.1.tar.gz
Algorithm Hash digest
SHA256 f8a240fa68882166865999ca6a7b1edd051b8ff3d5c78ea2161d9aacd79f1088
MD5 64ede104f98c6d38d142e935d46b081b
BLAKE2b-256 0ccafcbd9a2efccce2fa42fd67f872d5cc37083a880f1eee96355898ea51ef89

See more details on using hashes here.

File details

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

File metadata

  • Download URL: safethread-1.3.1-py3-none-any.whl
  • Upload date:
  • Size: 25.2 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.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 017fd07e3ee3e688e8f16aa3a17652b9432d0f67958ca93f85cd0a436205d6d6
MD5 5c85edc831a397d98090a4c52c0c0e01
BLAKE2b-256 1facb39429bf6a53d7008d34aff1e193c46f460acb47eef576424e6e8df8d5a0

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