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
詳しくは docs/user/interlocking.md を参照してください。
開発
uv sync
uv run pytest
設計方針は .github/copilot-instructions.md の Design Principles、決定事項は docs/dev/adr/ を参照してください。
ライセンス
MIT
Metadata
Release files for interlocking 0.0.1
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.0.1.tar.gz | 22.7 kB | Without provenance | Details for interlocking-0.0.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| interlocking-0.0.1-py3-none-any.whl | Python 3 | none | any | Details for interlocking-0.0.1-py3-none-any.whl |
Total release size: 50.3 kB
Release files / interlocking-0.0.1.tar.gz
| Download URL | interlocking-0.0.1.tar.gz |
|---|---|
| Size | 22.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
af3d65b8d8a30af9d05963f86db04fd0a60117a45b549575e816e79ad721b609
|
|
BLAKE2b-256 checksum How to use checksums |
cdecd61c7bdaba2ba2f561e11627b36bcf1766fd1806c1519980eebdb7698bf2
|
| 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.0.1-py3-none-any.whl
| Download URL | interlocking-0.0.1-py3-none-any.whl |
|---|---|
| Size | 27.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
98d8e0316cb9bbf23ce2a5c03aef68d00670926c080fb9456a68420f56ab642e
|
|
BLAKE2b-256 checksum How to use checksums |
96e1f2f7f3803526cf86d46c807c5181285684364725cc88752259608b4d9992
|
| 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.0.1
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.