Fix local client registration to prevent disconnection

- Changed local client ID to 'local' and marked as local to prevent cleanup
- Local clients are not cleaned up after 60 seconds
- Prevents 'Client local disconnected' messages
parent 50877d40
...@@ -161,10 +161,10 @@ class ClusterMaster: ...@@ -161,10 +161,10 @@ class ClusterMaster:
gpu_info = detect_gpu_backends() gpu_info = detect_gpu_backends()
available_backends = get_available_backends() available_backends = get_available_backends()
client_id = "local_master" client_id = "local"
hostname = "localhost" hostname = "localhost"
# Register as a client # Register as a local client (not via websocket)
self.clients[client_id] = { self.clients[client_id] = {
'token': 'local', 'token': 'local',
'hostname': hostname, 'hostname': hostname,
...@@ -175,7 +175,8 @@ class ClusterMaster: ...@@ -175,7 +175,8 @@ class ClusterMaster:
'connected': True, 'connected': True,
'last_seen': time.time(), 'last_seen': time.time(),
'consecutive_failures': 0, 'consecutive_failures': 0,
'failing': False 'failing': False,
'local': True # Mark as local to prevent disconnection
} }
# Register processes # Register processes
...@@ -527,7 +528,7 @@ class ClusterMaster: ...@@ -527,7 +528,7 @@ class ClusterMaster:
await self._transfer_job_files(client_id, job_data, job_id) await self._transfer_job_files(client_id, job_data, job_id)
# Send job assignment # Send job assignment
if client_id == "local_master": if client_id == "local":
# Handle local job assignment # Handle local job assignment
return await self._assign_local_job(worker_key, job_data) return await self._assign_local_job(worker_key, job_data)
elif client_id in self.client_websockets: elif client_id in self.client_websockets:
...@@ -579,7 +580,7 @@ class ClusterMaster: ...@@ -579,7 +580,7 @@ class ClusterMaster:
vram_required = estimate_model_vram_requirements(model_path) vram_required = estimate_model_vram_requirements(model_path)
self.active_jobs[job_id] = { self.active_jobs[job_id] = {
'worker_key': worker_key, 'worker_key': worker_key,
'client_id': client_id, 'client_id': "local",
'model_path': model_path, 'model_path': model_path,
'vram_required': vram_required, 'vram_required': vram_required,
'start_time': time.time(), 'start_time': time.time(),
...@@ -1211,6 +1212,8 @@ class ClusterMaster: ...@@ -1211,6 +1212,8 @@ class ClusterMaster:
current_time = time.time() current_time = time.time()
dead_clients = [] dead_clients = []
for client_id, client_info in self.clients.items(): for client_id, client_info in self.clients.items():
if client_info.get('local'):
continue # Don't clean up local clients
if current_time - client_info['last_seen'] > 60: # 1 minute timeout if current_time - client_info['last_seen'] > 60: # 1 minute timeout
dead_clients.append(client_id) dead_clients.append(client_id)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment