safethread
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).
Metadata
Release files for safethread 2.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| safethread-2.0.0.tar.gz | 28.0 kB | Without provenance | Details for safethread-2.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| safethread-2.0.0-py3-none-any.whl | Python 3 | none | any | Details for safethread-2.0.0-py3-none-any.whl |
Total release size: 63.1 kB
Release files / safethread-2.0.0.tar.gz
| Download URL | safethread-2.0.0.tar.gz |
|---|---|
| Size | 28.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a6cbd4b2acbbfc0a116f0677549c7bbf06602616f880bd2981509491a1c573dd
|
|
BLAKE2b-256 checksum How to use checksums |
2dc00063d59f063df08bf989e38f0a83f74033c7dbf7b83eaabd7dfe96727519
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.1
|
Release files / safethread-2.0.0-py3-none-any.whl
| Download URL | safethread-2.0.0-py3-none-any.whl |
|---|---|
| Size | 35.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
3e841057f14bb752fe9b7f29ab0ca03092e1cd0381e17bb42c3d4e017057ef84
|
|
BLAKE2b-256 checksum How to use checksums |
1d1256e07089928588ab3b2ed9e99d66a369cb76e4bf6ab484ec7cdd8925876c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.1
|
Security for safethread 2.0.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.