plesty.lib.utils.registry

Resource registry and local IP utilities for Plesty.

Classes

ResourceRegistry

Global registry for tracking active device resource instances.

Functions

get_local_ip(→ str)

Return the local IP address of this machine.

Module Contents

class plesty.lib.utils.registry.ResourceRegistry

Global registry for tracking active device resource instances.

_active_resources: dict[Any, weakref.ref[Any]]
classmethod acquire(key: Any, obj: Any) None

Register a resource under key, raising RuntimeError if already in use.

A key whose previous holder has been garbage-collected (a dead weak reference) counts as free: the lock only guards against two live instances holding the same resource, so a stale entry is reclaimed rather than blocking acquisition.

Parameters:
  • key (Any)

  • obj (Any)

Return type:

None

classmethod release(key: Any) None

Release a registered resource by key.

Parameters:

key (Any)

Return type:

None

plesty.lib.utils.registry.get_local_ip() str

Return the local IP address of this machine.

Return type:

str