controller
dev_tool.launcher.ipc.controller
log = logging.getLogger(__name__)
module-attribute
AntiAustinMechanism
A class for ensuring only one instance of the application runs at a time.
This class uses a network socket to lock a port and prevent multiple instances.
The constructor for the AntiAustinMechanism class.
Parameters:
-
base_port(int, default:6666) –The base port number for socket binding.
-
host(str, default:'127.0.0.1') –The host address for socket binding.
Source code in dev_tool/launcher/ipc/controller.py
base_port = base_port
instance-attribute
host = host
instance-attribute
connection = None
instance-attribute
lock_port = 0
instance-attribute
ipc_port = 0
instance-attribute
ipc_server = None
instance-attribute
__enter__
The context manager entry method that acquires the lock.
Returns:
-
Self–The AntiAustinMechanism instance.
__exit__
The context manager exit method that releases the lock.
Parameters:
-
exc_type(type[BaseException] | None) –The exception type, if an exception was raised.
-
exc_val(BaseException | None) –The exception value, if an exception was raised.
-
traceback(object) –The traceback, if an exception was raised.
Source code in dev_tool/launcher/ipc/controller.py
acquire_lock
A method that acquires the lock by binding to a socket.
If the lock cannot be acquired, this method will prompt the user to send a shutdown command to the running instance.
Source code in dev_tool/launcher/ipc/controller.py
start_ipc_server
A method that starts the IPC server for handling shutdown commands.
Parameters:
-
shutdown_callback(Callable[[], None]) –The callback function to call when a shutdown command is received.
Source code in dev_tool/launcher/ipc/controller.py
release_lock
A method that releases the lock by closing the socket and stopping the IPC server.