mirror of
https://github.com/GNS3/gns3-server.git
synced 2026-11-06 07:11:13 +02:00
refactor: ruff autofixes
This commit is contained in:
39 files changed
+76
-88
No files matched your search
@@ -685,7 +685,7 @@ class AgentService:
|
||||
"Checkpointer connection closed for: %s",
|
||||
self.project_path,
|
||||
)
|
||||
except asyncio.TimeoutError:
|
||||
except TimeoutError:
|
||||
log.warning(
|
||||
"Checkpointer connection close timeout for: %s (forcing cleanup)",
|
||||
self.project_path,
|
||||
|
||||
@@ -215,7 +215,7 @@ async def wait_for_mcp_ready() -> bool:
|
||||
await asyncio.wait_for(_mcp_ready_event.wait(), timeout=5.0)
|
||||
log.debug("MCP server is now ready, proceeding with connection")
|
||||
return True
|
||||
except asyncio.TimeoutError:
|
||||
except TimeoutError:
|
||||
log.warning("MCP server ready check timed out after 5 seconds - GNS3 server initialization may have issues")
|
||||
return False
|
||||
|
||||
|
||||
@@ -21,7 +21,6 @@ Web Wireshark - Docker HTTP API client
|
||||
This module handles Docker API operations via aiohttp Unix socket.
|
||||
"""
|
||||
|
||||
import asyncio
|
||||
import logging
|
||||
from asyncio import timeout as async_timeout
|
||||
from typing import Any
|
||||
@@ -142,7 +141,7 @@ class DockerHTTPClient:
|
||||
if response.status == 204: # No Content
|
||||
return None
|
||||
return await response.json()
|
||||
except asyncio.TimeoutError:
|
||||
except TimeoutError:
|
||||
raise RuntimeError(f"Docker API timeout after {self.REQUEST_TIMEOUT}s for {endpoint}")
|
||||
except aiohttp.ClientError as e:
|
||||
raise RuntimeError(f"Docker connection error: {e}") from e
|
||||
@@ -256,7 +255,7 @@ class DockerHTTPClient:
|
||||
error_text = await response.text()
|
||||
raise RuntimeError(f"Docker API error {response.status}: {error_text}")
|
||||
result = await response.json()
|
||||
except asyncio.TimeoutError:
|
||||
except TimeoutError:
|
||||
raise RuntimeError(f"Docker API timeout after {self.REQUEST_TIMEOUT}s for containers/{container_name}/top")
|
||||
except aiohttp.ClientError as e:
|
||||
raise RuntimeError(f"Docker connection error: {e}") from e
|
||||
|
||||
@@ -75,7 +75,7 @@ class WebWiresharkManager:
|
||||
)
|
||||
stdout, _ = await asyncio.wait_for(proc.communicate(), timeout=self.CONTAINER_EXEC_TIMEOUT)
|
||||
return proc.returncode == 0 and b"ping" in stdout
|
||||
except asyncio.TimeoutError:
|
||||
except TimeoutError:
|
||||
logger.warning(f"Container {container_id[:12]} health check timeout")
|
||||
return False
|
||||
except FileNotFoundError:
|
||||
@@ -113,12 +113,12 @@ class WebWiresharkManager:
|
||||
try:
|
||||
stdout, stderr = await asyncio.wait_for(proc.communicate(), timeout=timeout)
|
||||
return (proc.returncode, stdout.decode().strip(), stderr.decode().strip())
|
||||
except asyncio.TimeoutError:
|
||||
except TimeoutError:
|
||||
logger.error(f"Command timeout after {timeout}s: {command}")
|
||||
proc.terminate()
|
||||
try:
|
||||
await asyncio.wait_for(proc.wait(), timeout=2)
|
||||
except asyncio.TimeoutError:
|
||||
except TimeoutError:
|
||||
proc.kill()
|
||||
return (-1, "", f"timeout after {timeout}s")
|
||||
except Exception as e:
|
||||
|
||||
Reference in new issue
Block a user