Metadata-Version: 2.4
Name: procwire
Version: 5.2.6
Summary: Process lifecycle orchestration and task piping for Python services
Home-page: https://github.com/dpetrov-oss/procwire
Author: Dmitri Petrov
Author-email: dpetrov-oss@proton.me
License: MIT
Keywords: process spawn task pipe lifecycle daemon fork worker orchestration
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: schemavault
Requires-Dist: bytekit
Dynamic: author
Dynamic: author-email
Dynamic: classifier
Dynamic: description
Dynamic: description-content-type
Dynamic: home-page
Dynamic: keywords
Dynamic: license
Dynamic: license-file
Dynamic: requires-dist
Dynamic: requires-python
Dynamic: summary

# procwire

Process lifecycle orchestration and task piping for Python services. Manage spawned processes with tracking, timeout control, and event-driven lifecycle hooks.

## Installation

```bash
pip install procwire
```

## Usage

```python
import procwire

# Spawn a tracked background process
worker = procwire.spawn('my-worker', 'python', ['-m', 'myapp.worker'], timeout=30000)
print(f"Worker PID: {worker['pid']}")

# Check process status
info = procwire.status('my-worker')
print(f"Running: {info['running']}, Uptime: {info['uptime']:.1f}s")

# Run synchronous command with captured output
result = procwire.run_sync('git', ['status', '--short'], timeout=10)
print(result['stdout'])

# Lifecycle events
procwire.on('exit', lambda name, code: print(f'{name} exited: {code}'))
procwire.on('timeout', lambda name, ms: print(f'{name} timed out after {ms}ms'))

# Restart crashed workers
procwire.restart('my-worker', 'python', ['-m', 'myapp.worker'])

# Graceful shutdown
procwire.cleanup()
```

## API

### Process Management
- `spawn(name, cmd, args=None, timeout=None, detached=True, hide=True)` â€” spawn tracked process
- `spawn_shell(name, command, timeout=None)` â€” spawn via shell
- `run_sync(cmd, args=None, timeout=30, capture=True)` â€” run and wait
- `kill(name, sig=None)` â€” terminate tracked process
- `restart(name, cmd=None, args=None, **kwargs)` â€” kill and respawn

### Status
- `list_processes()` â€” list tracked names
- `has(name)` â€” check if tracked
- `status(name)` â€” get status dict
- `status_all()` â€” all statuses
- `is_running(name)` / `pid_of(name)` / `uptime(name)`

### Lifecycle
- `cleanup()` â€” kill all tracked processes
- `wait_all(timeout=None)` â€” wait for all to exit
- `on(event, fn)` / `once(event, fn)` / `off(event, fn)`

### Events
- `spawn` â€” process started
- `exit` â€” process exited
- `timeout` â€” process timed out
- `kill` â€” process killed

## License

MIT
