bpod_core.ipc.LocalServiceAdvertisement
- class bpod_core.ipc.LocalServiceAdvertisement
Bases:
AbstractContextManagerFile-based local service advertisement for IPC discovery.
Advertises a service by writing a JSON file to the user’s runtime directory. This provides a lightweight alternative to Zeroconf for discovering services on the same machine. Stale advertisements (from dead processes) are automatically cleaned up during discovery.
The advertisement is automatically removed when the instance is garbage collected or when stop() is called explicitly.
- static discover(service_type, properties=None) Iterator[LocalServiceInfo]
Discover locally advertised services.
- Parameters:
- Yields:
LocalServiceInfo– Information structure describing the discovered services.- Return type:
- __init__(service_name, service_type, address, properties=None, *, pid=None, uuid=None) None
Create a local service advertisement.
- Parameters:
service_name (
str) – The name of the service being advertised (e.g., ‘Bpod 3’).service_type (
str) – The type of service being advertised (e.g., ‘bpod’).address (
str) – The address where the service can be reached (e.g., ‘ipc:///tmp/foo.ipc’).properties (
dict, optional) – Additional key-value properties to advertise with the service.pid (
int, optional) – Process ID of the service. Used to detect stale advertisements.uuid (
UUID4, optional) – Unique identifier for this service instance. Generated if not provided.
- Return type:
None
- runtime_directory = PosixPath('/run/user/1001/LocalServiceAdvertisements')
Directory where service advertisement files are stored.
-
service_file:
Path Path to the advertisement file.