{"id":19208637,"url":"https://github.com/heiwa4126/python_flock_ex1","last_synced_at":"2025-10-10T13:43:14.387Z","repository":{"id":111910385,"uuid":"397064933","full_name":"heiwa4126/python_flock_ex1","owner":"heiwa4126","description":"Python 3で複数プロセスでflockを使って排他制御を行うサンプルコード","archived":false,"fork":false,"pushed_at":"2021-08-17T02:52:56.000Z","size":4,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-23T07:16:33.099Z","etag":null,"topics":["example","flock","python"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/heiwa4126.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-08-17T02:37:08.000Z","updated_at":"2021-08-19T01:48:14.000Z","dependencies_parsed_at":"2023-04-18T14:30:43.309Z","dependency_job_id":null,"html_url":"https://github.com/heiwa4126/python_flock_ex1","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/heiwa4126/python_flock_ex1","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/heiwa4126%2Fpython_flock_ex1","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/heiwa4126%2Fpython_flock_ex1/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/heiwa4126%2Fpython_flock_ex1/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/heiwa4126%2Fpython_flock_ex1/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/heiwa4126","download_url":"https://codeload.github.com/heiwa4126/python_flock_ex1/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/heiwa4126%2Fpython_flock_ex1/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279004069,"owners_count":26083667,"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","status":"online","status_checked_at":"2025-10-10T02:00:06.843Z","response_time":62,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["example","flock","python"],"created_at":"2024-11-09T13:27:15.726Z","updated_at":"2025-10-10T13:43:14.364Z","avatar_url":"https://github.com/heiwa4126.png","language":"Python","readme":"# python_flock_ex1\n\nPython 3で複数プロセスでflockを使って排他制御を行うサンプルコード。\nflock()を使っているのでUNIXのみ動く。詳しくは`man 2 flock`参照。\n\n\n# 動かし方\n\n- init_cnt.py - カウンターを0に初期化\n- inc_cnt.py - カウンターを10000増やす(排他制御なし)。並行で複数動かすと死ぬ。\n- flock_inc_cnt.py - カウンターを10000増やす。並行で動かしても死なない。\n\n```sh\n# 期待通りに動く\n./init_cnt.py ; ./inc_cnt.py\n\n# 死ぬ。または30000にならない\n./init_cnt.py ; ./inc_cnt.py \u0026 ./inc_cnt.py \u0026 ./inc_cnt.py\n\n# 30000になる\n./init_cnt.py ; ./flock_inc_cnt.py \u0026 ./flock_inc_cnt.py \u0026 ./flock_inc_cnt.py\n```\n\n# そのほかメモ\n\nCOUNTER_FILEと別にLOCK_FILEが必要なのは、\nCOUNTER_FILEをオープンした時点でバッファされてしまうからだと思う。\n\nあと、例外の補足をしてないのがよろしくないので\n(ロックファイルが開放されない)\nあとで追加する。 -\u003e 追加しました\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fheiwa4126%2Fpython_flock_ex1","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fheiwa4126%2Fpython_flock_ex1","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fheiwa4126%2Fpython_flock_ex1/lists"}