Interlocking
One track, one train.
Easy to run. Explicit to control.
interlocking は、分散環境におけるバックグラウンドタスクの実行管理フレームワークです。 名前は鉄道の連動装置(同じ軌道に同時に列車を入れないよう進路を制御する仕組み)に由来し、排他制御を核に据えています。 鉄道メタファーにより、バッチタスクのライフサイクル(排他制御・実行記録・CLI 統合)を統一された方法で管理します。
特長
- 排他制御: 同じタスクを同時に走らせない。
- 実行記録: 直近の実行結果を記録し、次回実行に引き継ぐ(
Coupler)。 - CLI 統合: 型ヒントからコマンドラインを組み立て、結果を終了コードで返す。
- 差し込み:
Station(ストレージ)やTrainMiddlewareで、振る舞いを拡張できる。
最小構成
# tasks.py
from typing import Annotated
from interlocking import Line, Coupler
line = Line()
@line.track(name="daily", help="日次処理")
def daily_task(c: Coupler, target_date: Annotated[str, "対象日付 (YYYY-MM-DD)"]) -> dict:
last_id = c.last_data.get("last_id", 0)
# ... 処理 ...
return {"last_id": 9999}
# main.py
import sys
from interlocking import TrainDispatcher, LocalStation, InterlockingCLI
dispatcher = TrainDispatcher(
station=LocalStation(base_path=".interlocking"),
lines={"batch": "tasks:line"},
)
cli = InterlockingCLI(dispatcher=dispatcher, prog="my-task", description="バッチタスク")
sys.exit(cli.execute(cli.parse_args())) # 結果を終了コードで伝える
python main.py batch daily start --target-date 2026-04-01
開発
uv sync
uv run pytest
ライセンス
MIT
Metadata
Release files for interlocking 0.1.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 |
|---|---|---|---|---|
| interlocking-0.1.0.tar.gz | 22.7 kB | Without provenance | Details for interlocking-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| interlocking-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for interlocking-0.1.0-py3-none-any.whl |
Total release size: 50.3 kB
Release files / interlocking-0.1.0.tar.gz
| Download URL | interlocking-0.1.0.tar.gz |
|---|---|
| Size | 22.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
bcc49dc3be5fb4fa12dc0b0996a241fbeaabb740f82b2e980945d1329e55fb36
|
|
BLAKE2b-256 checksum How to use checksums |
f612434a452f3ba15002de3597d4c8255e7e73c880269e9468e41cbfed0c252a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.13.5 {"installer":{"name":"uv","version":"0.13.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Release files / interlocking-0.1.0-py3-none-any.whl
| Download URL | interlocking-0.1.0-py3-none-any.whl |
|---|---|
| Size | 27.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
59e9ce80b9108d5bc511baa18d5a5a4c469b9c309b58d97e990548f5f62cd92c
|
|
BLAKE2b-256 checksum How to use checksums |
a06f3cdf51b624278fdae2e4ff316d1105fd80ce2670c97942ba29e97385a631
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.13.5 {"installer":{"name":"uv","version":"0.13.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Security for interlocking 0.1.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.