SPECTER
Service Primitives for Event Control, Teardown, and Execution Runtime
A lifecycle-first backend framework for Python applications built on Flask and gevent. SPECTER is designed around three ideas: explicit ownership of background work, deterministic teardown, and clear service boundaries.
Requirements
- Python 3.9+
Stack
If you use SPECTER, the main runtime dependencies you will be building against are:
- Flask for HTTP app and route integration
- gevent for concurrency, timers, greenlets, and synchronization
- Flask-SocketIO for websocket and socket event integration
Install
Install from PyPI:
pip install specter-runtime
This will install SPECTER and its required runtime dependencies.
Import it as specter:
from specter import Service, Controller, Schema, Field, boot, registry, bus
Primitives
| Channel | Role |
|---|---|
Service |
Lifecycle owner for background work (timers, greenlets, bus subscriptions) |
QueueService |
Queue-backed worker pool with managed startup/shutdown |
Controller |
Feature composition root — binds routes, socket events, and state under one lifecycle |
Handler |
Class-based Socket.IO event lifecycle |
SocketIngress |
Shared socket fanout dispatcher (multiple listeners per event with priority) |
Watcher |
Polling or stream-following observation loop with retry/backoff |
Schema / Field |
Declarative payload validation and coercion |
create_store |
Shared mutable flat state (gevent-safe) |
create_model |
Nested runtime state graph with path selectors |
create_cache |
Shared state with TTL expiry and bus-driven invalidation cascades |
Outcome |
Structured success/failure result |
Operation |
Reusable validate + perform action |
ManagedProcess |
Subprocess lifecycle with owned stream readers |
Router + route |
Class-based Flask Blueprint composition |
registry |
Composition-root service locator with late binding |
bus |
Internal synchronous pub/sub |
json_endpoint |
Flask route decorator for consistent JSON error envelopes |
Quick Examples
Service
from specter import Service
class PollingService(Service):
def __init__(self):
super().__init__('polling', {'tick_count': 0})
def on_start(self):
self.interval(self._tick, 10.0)
def _tick(self):
self.set_state({'tick_count': self.state.get('tick_count', 0) + 1})
service = PollingService().start()
# later
service.stop()
Controller
from flask import request
from specter import Controller, Field, Schema
class ItemController(Controller):
name = 'items'
schemas = {
'create': Schema('create', {
'name': Field(str, required=True),
'active': Field(bool, default=True),
})
}
def on_start(self):
self.state = self.create_model('items.state', {'items': []})
def build_routes(self, router):
@router.route('/api/items', methods=['POST'])
def create():
clean = self.schema('create').require(request.get_json(silent=True) or {})
return {'ok': True, 'name': clean['name']}
def build_events(self, handler):
handler.on('item_created', self._on_item_created)
def _on_item_created(self, data=None):
return {'ok': True}
Boot
from specter import boot
manager = boot(
app,
socketio,
services=[ThumbnailService(), IndexService()],
controllers=[ItemController()],
)
Documentation
See specter.md for the full guide and API reference.
License
Apache 2.0 — Copyright 2026 BleedingXiko
Release files for specter-runtime 0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| specter_runtime-0.1.2.tar.gz | 46.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| specter_runtime-0.1.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 111.1 kB
Release files / specter_runtime-0.1.2.tar.gz
| Download URL | specter_runtime-0.1.2.tar.gz |
|---|---|
| Size | 46.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4eaf37dc51da0f0240247fd609745a88d7b5330bd3287bf166b1e3f257bfb2fa
|
|
BLAKE2b-256 checksum How to use checksums |
4ac741f2e2c496806a35ece7c23fce66bfe6740f5e5e7b776778b40e3874e1fa
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.6
|
Release files / specter_runtime-0.1.2-py3-none-any.whl
| Download URL | specter_runtime-0.1.2-py3-none-any.whl |
|---|---|
| Size | 64.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
43a51bc26ac0da4a3d9965d00fed6f3efc361d8fc738d9df67b86a8318737b32
|
|
BLAKE2b-256 checksum How to use checksums |
5bcb57893dd066ce0cd02bb97975a0ba9880ef44ce53d0cce76710ee89ebc18c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.6
|