https://github.com/hamiltonkibbe/tutti
Distributed Synchronization for Python
https://github.com/hamiltonkibbe/tutti
distributed-systems lock mutex python semaphore synchronization
Last synced: 4 months ago
JSON representation
Distributed Synchronization for Python
- Host: GitHub
- URL: https://github.com/hamiltonkibbe/tutti
- Owner: hamiltonkibbe
- License: mit
- Created: 2021-10-21T04:16:13.000Z (almost 5 years ago)
- Default Branch: main
- Last Pushed: 2025-02-26T18:20:44.000Z (over 1 year ago)
- Last Synced: 2025-02-26T19:28:35.606Z (over 1 year ago)
- Topics: distributed-systems, lock, mutex, python, semaphore, synchronization
- Language: Python
- Homepage: https://pypi.org/project/tutti/
- Size: 74.2 KB
- Stars: 4
- Watchers: 4
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README

*adverb* -- with all voices or instruments together.
# Distributed Synchronization for Python
Tutti is a nearly drop-in replacement for python's built-in synchronization primitives that lets you fearlessly scale
your code across processes, machines, clouds and planets.
Full Documentation available [on Read The Docs](https://tutti-py.readthedocs.io/en/latest/)
## Features
- Mostly compatible with `threading` primitives
- Redis backend (Azure and AWS backends on the roadmap)
## Installation
The easiest way to install is to just use `pip`:
pip install tutti
## Example
```python
from tutti import Lock
from tutti import Semaphore
from tutti.asyncio import Lock as AsyncLock
from tutti.asyncio import Semaphore as AsyncSemaphore
from tutti.configuration import RedisLockConfig
from tutti.configuration import RedisSemaphoreConfig
REDIS_LOCK_CONFIG = RedisLockConfig(
connection_url="redis://localhost:6379/0",
name="test_lock",
timeout=10,
blocking=True,
)
REDIS_SEMAPHORE_CONFIG = RedisSemaphoreConfig(
connection_url="redis://localhost:6379/0",
name="test_semaphore",
max_concurrency=5,
lock_timeout=10
)
with Lock(REDIS_LOCK_CONFIG):
print("Locks!")
access_critical_resource()
with Semaphore(REDIS_SEMAPHORE_CONFIG):
print("Semaphores too!?")
access_less_critical_resource()
async with AsyncLock(REDIS_LOCK_CONFIG):
print("Synchronized across machines!")
await access_critical_resource()
async with AsyncSemaphore(REDIS_SEMAPHORE_CONFIG):
print("And it supports asyncio!?")
await access_critical_resource()
```
## License
`tutti` is offered under the MIT license.