{"id":20635760,"url":"https://github.com/orsinium-labs/dimutex","last_synced_at":"2025-07-07T07:09:56.995Z","repository":{"id":65600280,"uuid":"463148274","full_name":"orsinium-labs/dimutex","owner":"orsinium-labs","description":"asyncio Python library for distributed mutex with GCS as a backend","archived":false,"fork":false,"pushed_at":"2022-02-24T13:06:32.000Z","size":22,"stargazers_count":15,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-29T01:34:13.472Z","etag":null,"topics":["distributed-systems","gcp","gcs","google-cloud","google-cloud-platform","google-cloud-storage","mutex","python"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/orsinium-labs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-02-24T12:56:00.000Z","updated_at":"2024-07-31T15:28:31.000Z","dependencies_parsed_at":"2023-01-31T08:15:14.953Z","dependency_job_id":null,"html_url":"https://github.com/orsinium-labs/dimutex","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/orsinium-labs%2Fdimutex","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/orsinium-labs%2Fdimutex/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/orsinium-labs%2Fdimutex/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/orsinium-labs%2Fdimutex/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/orsinium-labs","download_url":"https://codeload.github.com/orsinium-labs/dimutex/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248606749,"owners_count":21132406,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["distributed-systems","gcp","gcs","google-cloud","google-cloud-platform","google-cloud-storage","mutex","python"],"created_at":"2024-11-16T15:07:20.485Z","updated_at":"2025-04-15T21:25:39.087Z","avatar_url":"https://github.com/orsinium-labs.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# dimutex\n\nPython library implementing [asyncio][asyncio]-based distributed mutex on top of different providers.\n\n[Mutex][mutex] is a synchronization primitive used to ensure that only one worker can do the given job. It can be used for safe access to a shared resource or for distributing tasks among multiple workers.\n\nCurrently, the only implemented provider is GCS (Google Cloud Storage). The implementation is based on the algorithm described in article [A robust distributed locking algorithm based on Google Cloud Storage][gcs-algo] (see also [Ruby implementation][ruby]).\n\n[asyncio]: https://docs.python.org/3/library/asyncio.html\n[mutex]: https://stackoverflow.com/questions/34524/what-is-a-mutex\n[gcs-algo]: https://www.joyfulbikeshedding.com/blog/2021-05-19-robust-distributed-locking-algorithm-based-on-google-cloud-storage.html\n[ruby]: https://github.com/FooBarWidget/distributed-lock-google-cloud-storage-ruby\n\n## Features\n\n+ Asynchronous.\n+ Type-safe.\n+ Atomic.\n+ Expiration mechanism to ensure that a single worker won't hold the lock forever.\n+ Supports emulators.\n\n## Installation\n\n```bash\npython3 -m pip install dimutex\n```\n\n## Usage\n\n```python\nimport dimutex\n\nasync def do_something():\n    lock = dimutex.GCS(bucket='bucket-name', name='lock-name')\n    # context manager makes sure to close aiohttp session\n    async with lock:\n        try:\n            await lock.acquire()\n        except dimutex.AlreadyAcquiredError:\n            return 'already acquired'\n        try:\n            # do something with the shared resource\n            ...\n            # update expiration if you need more time\n            await lock.refresh()\n            ...\n        finally:\n            await lock.release()\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Forsinium-labs%2Fdimutex","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Forsinium-labs%2Fdimutex","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Forsinium-labs%2Fdimutex/lists"}