{"id":37085225,"url":"https://github.com/hgdeoro/tcpnetlock","last_synced_at":"2026-01-14T10:28:36.940Z","repository":{"id":52704426,"uuid":"137520570","full_name":"hgdeoro/tcpnetlock","owner":"hgdeoro","description":"Network lock based on TCP sockets","archived":false,"fork":false,"pushed_at":"2021-04-20T17:37:16.000Z","size":160,"stargazers_count":1,"open_issues_count":4,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-09-09T10:56:01.744Z","etag":null,"topics":["backend-server","backend-services","batch-processing","locking","synchronization-service"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hgdeoro.png","metadata":{"files":{"readme":"README.rst","changelog":"HISTORY.rst","contributing":"CONTRIBUTING.rst","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-06-15T18:34:54.000Z","updated_at":"2018-07-20T20:09:21.000Z","dependencies_parsed_at":"2022-09-26T17:40:57.360Z","dependency_job_id":null,"html_url":"https://github.com/hgdeoro/tcpnetlock","commit_stats":null,"previous_names":[],"tags_count":17,"template":false,"template_full_name":null,"purl":"pkg:github/hgdeoro/tcpnetlock","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hgdeoro%2Ftcpnetlock","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hgdeoro%2Ftcpnetlock/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hgdeoro%2Ftcpnetlock/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hgdeoro%2Ftcpnetlock/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hgdeoro","download_url":"https://codeload.github.com/hgdeoro/tcpnetlock/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hgdeoro%2Ftcpnetlock/sbom","scorecard":{"id":463538,"data":{"date":"2025-08-11","repo":{"name":"github.com/hgdeoro/tcpnetlock","commit":"16c4adcc310d587b1a1e8a5abbd2e3bd2fc805c4"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":1.6,"checks":[{"name":"Code-Review","score":0,"reason":"Found 0/30 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":9,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Warn: project license file does not contain an FSF or OSI license."],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Pinned-Dependencies","score":0,"reason":"dependency not pinned by hash detected -- score normalized to 0","details":["Warn: containerImage not pinned by hash: docker/Dockerfile:1: pin your Docker image by updating alpine:3.7 to alpine:3.7@sha256:8421d9a84432575381bfabd248f1eb56f3aa21d9d7cd2511583c68c9b7511d10","Warn: downloadThenRun not pinned by hash: docker/Dockerfile:5-7","Warn: pipCommand not pinned by hash: docker/Dockerfile:14-15","Info:   0 out of   1 containerImage dependencies pinned","Info:   0 out of   1 downloadThenRun dependencies pinned","Info:   0 out of   1 pipCommand dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Vulnerabilities","score":0,"reason":"33 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: PYSEC-2021-421 / GHSA-h4m5-qpfp-3mpv","Warn: Project is vulnerable to: PYSEC-2022-42986 / GHSA-43fp-rhv2-5gv8","Warn: Project is vulnerable to: PYSEC-2023-135 / GHSA-xqr8-7jwr-rhp7","Warn: Project is vulnerable to: PYSEC-2024-60 / GHSA-jjg7-2v4v-x38h","Warn: Project is vulnerable to: PYSEC-2019-217 / GHSA-462w-v97r-4m45","Warn: Project is vulnerable to: GHSA-cpwx-vrp4-4pq7","Warn: Project is vulnerable to: PYSEC-2021-66 / GHSA-g3rq-g295-4j3m","Warn: Project is vulnerable to: GHSA-h5c8-rqwp-cp95","Warn: Project is vulnerable to: GHSA-h75v-3vvj-5mfj","Warn: Project is vulnerable to: GHSA-q2x7-8rv6-6q7h","Warn: Project is vulnerable to: PYSEC-2020-92 / GHSA-hj5v-574p-mj7c","Warn: Project is vulnerable to: PYSEC-2022-42969","Warn: Project is vulnerable to: PYSEC-2021-140 / GHSA-9w8r-397f-prfh","Warn: Project is vulnerable to: PYSEC-2023-117 / GHSA-mrwq-x4v8-fh7p","Warn: Project is vulnerable to: PYSEC-2021-141 / GHSA-pq64-v7f5-gqh8","Warn: Project is vulnerable to: PYSEC-2021-142 / GHSA-8q59-q68h-6hv4","Warn: Project is vulnerable to: PYSEC-2018-49 / GHSA-rprw-h62v-c2w7","Warn: Project is vulnerable to: GHSA-9hjg-9r4m-mvj7","Warn: Project is vulnerable to: GHSA-9wx4-h78v-vm56","Warn: Project is vulnerable to: PYSEC-2023-74 / GHSA-j8r2-6x86-q33q","Warn: Project is vulnerable to: PYSEC-2018-28 / GHSA-x84v-xcm2-53pg","Warn: Project is vulnerable to: GHSA-g7vv-2v7x-gj9p","Warn: Project is vulnerable to: GHSA-34jh-p97f-mpxf","Warn: Project is vulnerable to: PYSEC-2023-212 / GHSA-g4mx-q9vg-27p4","Warn: Project is vulnerable to: PYSEC-2023-207 / GHSA-gwvm-45gx-3cf8","Warn: Project is vulnerable to: PYSEC-2019-133 / GHSA-mh33-7rrq-662w","Warn: Project is vulnerable to: GHSA-pq67-6m6q-mj2v","Warn: Project is vulnerable to: PYSEC-2019-132 / GHSA-r64q-w8jr-g9qp","Warn: Project is vulnerable to: PYSEC-2023-192 / GHSA-v845-jxx5-vc9f","Warn: Project is vulnerable to: PYSEC-2020-148 / GHSA-wqvq-5m8c-6g24","Warn: Project is vulnerable to: PYSEC-2021-108","Warn: Project is vulnerable to: PYSEC-2024-187 / GHSA-rqc4-2hc7-8c8v","Warn: Project is vulnerable to: PYSEC-2022-43017 / GHSA-qwmp-2cf2-g9g6"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-19T11:50:04.067Z","repository_id":52704426,"created_at":"2025-08-19T11:50:04.067Z","updated_at":"2025-08-19T11:50:04.067Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28417250,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T10:25:19.714Z","status":"ssl_error","status_checked_at":"2026-01-14T10:22:49.371Z","response_time":107,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["backend-server","backend-services","batch-processing","locking","synchronization-service"],"created_at":"2026-01-14T10:28:36.146Z","updated_at":"2026-01-14T10:28:36.934Z","avatar_url":"https://github.com/hgdeoro.png","language":"Python","readme":"==========\nTcpNetLock\n==========\n\n\n.. image:: https://img.shields.io/pypi/v/tcpnetlock.svg\n        :target: https://pypi.python.org/pypi/tcpnetlock\n\n.. image:: https://img.shields.io/travis/hgdeoro/tcpnetlock.svg\n        :target: https://travis-ci.org/hgdeoro/tcpnetlock\n\n.. image:: https://readthedocs.org/projects/tcpnetlock/badge/?version=latest\n        :target: https://tcpnetlock.readthedocs.io/en/latest/?badge=latest\n        :alt: Documentation Status\n\n\n.. image:: https://pyup.io/repos/github/hgdeoro/tcpnetlock/shield.svg\n     :target: https://pyup.io/repos/github/hgdeoro/tcpnetlock/\n     :alt: Updates\n\n\n\nNetwork lock based on TCP sockets\n---------------------------------\n\n\n* Free software: GNU General Public License v3\n* Documentation: https://tcpnetlock.readthedocs.io/\n* GitHub: https://github.com/hgdeoro/tcpnetlock/\n* Docker: https://hub.docker.com/r/hgdeoro/tcpnetlock/\n\n\nWhy?\n----\n\nWhile deploying applications to Kubernetes, I needed a way to make sure that\nsome potential concurrent, distributed actions, are not executed concurrently.\nFor example:\n\n* **database migrations**: just one Pod in the Kubernetes cluster should be able to apply the database migrations\n* for **batch jobs**, different workers could be working on the same resource, this can be avoided with this lock mechanism\n\nOf course, Zookeeper is a MUCH BETTER solution, but that's too much for my use cases...\n\nHow it works\n------------\n\nAssuming the server is running on localhost, let's get a lock using telnet::\n\n    $ telnet localhost 7654\n    Trying 127.0.0.1...\n    Connected to localhost.\n    Escape character is '^]'.\n\nTo try to acquire a lock, send::\n\n    lock,name:django-migrations\n\nServer responds with::\n\n    ok\n\nFrom that point, and while the TCP connection is open, you have the lock.\n\nIf you try the same in a different terminal, you will get::\n\n    $ telnet localhost 7654\n    Trying 127.0.0.1...\n    Connected to localhost.\n    Escape character is '^]'.\n    lock,name:django-migrations        \u003c= you write\n    not-granted                        \u003c= server response\n    Connection closed by foreign host. \u003c= server closed the connection\n\nHere the server responded with **not-granted** and closed the TCP connection. The lock was not granted to you.\n\nBut, in real-life scenarios, you would use the provided utility **tcpnetlock_do**::\n\n    $ tcpnetlock_do --lock-name django-migrations -- python manage.py migrate\n\nTo test it, you will need the server running. To get the server running with Docker, just run::\n\n    $ docker pull hgdeoro/tcpnetlock\n    $ docker run -ti --rm -p 7654:7654 hgdeoro/tcpnetlock\n\nAlternatively, you can install the package in a virtualenv and launch the server::\n\n    $ virtualenv -p python3.6 venv\n    $ source venv/bin/activate\n    $ pip install tcpnetlock\n    $ tcpnetlock_server --info\n    INFO:root:Started server listening on localhost:7654\n\n\nFeatures\n--------\n\n* Runs on Python 3.6 / Python 3.5\n* Do not require external libraries\n* Ready to use Docker image (based on Alpine)\n* Includes server and python client\n* Includes utility to run Linux commands while holding the lock\n* Simple protocol: you can get a lock even with *netcat*\n\nAppendix: netcat\n----------------\n\nSince the protocol is just text over a TCP connection, you can get a lock just writing the\nright text overt the TCP connection and leaving that TCP connection open, and that's the default\nbehaviour of netcat::\n\n    $ echo 'lock,name:LOCK_NAME' | nc localhost 7654\n\nThe first line uses netcat to open the TCP connection and tries to get the lock.\n\nThe biggest problem would be to READ the response to the server (will be one of 'ok' or 'not-granted') while\nsend `nc` to the background. We can use a `fifo` for that::\n\n    $ echo 'lock,name:LOCK_NAME' | nc -v localhost 7654 | tee /tmp/.tcpnetlock \u0026\n    $ result=$(head -n 1 /tmp/.tcpnetlock)\n\nEven though this works, using one of the two existing python clients (`tnl_client` and `tnl_do`) would be much better.\n\n\nCredits\n-------\n\nThis package was created with Cookiecutter_ and the `audreyr/cookiecutter-pypackage`_ project template.\n\n.. _Cookiecutter: https://github.com/audreyr/cookiecutter\n.. _`audreyr/cookiecutter-pypackage`: https://github.com/audreyr/cookiecutter-pypackage\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhgdeoro%2Ftcpnetlock","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhgdeoro%2Ftcpnetlock","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhgdeoro%2Ftcpnetlock/lists"}