diff --git a/gns3server/agent/gns3_copilot/agent_service.py b/gns3server/agent/gns3_copilot/agent_service.py
index be6ed201d..5c58cd4e1 100644
--- a/gns3server/agent/gns3_copilot/agent_service.py
+++ b/gns3server/agent/gns3_copilot/agent_service.py
@@ -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,
diff --git a/gns3server/agent/mcp/__init__.py b/gns3server/agent/mcp/__init__.py
index 57b45e5ea..2a39bdb5f 100644
--- a/gns3server/agent/mcp/__init__.py
+++ b/gns3server/agent/mcp/__init__.py
@@ -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
diff --git a/gns3server/agent/web_wireshark/docker_client.py b/gns3server/agent/web_wireshark/docker_client.py
index e030eab35..23c45aef5 100644
--- a/gns3server/agent/web_wireshark/docker_client.py
+++ b/gns3server/agent/web_wireshark/docker_client.py
@@ -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
diff --git a/gns3server/agent/web_wireshark/manager.py b/gns3server/agent/web_wireshark/manager.py
index 0791c0668..6efeaa19d 100644
--- a/gns3server/agent/web_wireshark/manager.py
+++ b/gns3server/agent/web_wireshark/manager.py
@@ -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:
diff --git a/gns3server/api/routes/controller/nodes.py b/gns3server/api/routes/controller/nodes.py
index 988524835..bacffe34f 100644
--- a/gns3server/api/routes/controller/nodes.py
+++ b/gns3server/api/routes/controller/nodes.py
@@ -435,7 +435,7 @@ async def _run_lifecycle(
return node.asdict()
try:
await asyncio.wait_for(_run(), timeout)
- except asyncio.TimeoutError:
+ except TimeoutError:
raise ControllerTimeoutError(f"Timeout when waiting for {node.name} to be {target}")
return node.asdict()
@@ -711,7 +711,7 @@ async def get_file(file_path: str, node: Node = Depends(dep_node)) -> Response:
try:
async for chunk in compute_resp.content.iter_chunked(65536):
yield chunk
- except (OSError, asyncio.TimeoutError) as e:
+ except (TimeoutError, OSError) as e:
log.error(f"Error streaming file '{path}' from compute: {e}")
raise
finally:
diff --git a/gns3server/compute/docker/__init__.py b/gns3server/compute/docker/__init__.py
index 18d180e2b..b8edf5a21 100644
--- a/gns3server/compute/docker/__init__.py
+++ b/gns3server/compute/docker/__init__.py
@@ -323,7 +323,7 @@ class Docker(BaseManager):
)
except aiohttp.ClientError as e:
raise DockerError(f"Docker has returned an error: {e}")
- except asyncio.TimeoutError:
+ except TimeoutError:
raise DockerError("Docker timeout " + method + " " + path)
if response.status >= 300:
body = await response.read()
@@ -391,7 +391,7 @@ class Docker(BaseManager):
raise DockerError(
f"Disconnected while pulling Docker image '{image}' from Docker repository"
) from e
- except asyncio.TimeoutError as e:
+ except TimeoutError as e:
raise DockerError(f"Timeout while pulling Docker image '{image}' from Docker repository") from e
if not chunk:
break
@@ -448,7 +448,7 @@ class Docker(BaseManager):
chunk = await response.content.read(CHUNK_SIZE)
except aiohttp.ServerDisconnectedError as e:
raise DockerError("Disconnected while loading Docker image") from e
- except asyncio.TimeoutError as e:
+ except TimeoutError as e:
raise DockerError("Timeout while loading Docker image") from e
if not chunk:
break
diff --git a/gns3server/compute/docker/docker_vm.py b/gns3server/compute/docker/docker_vm.py
index 0612ff235..c0a093942 100644
--- a/gns3server/compute/docker/docker_vm.py
+++ b/gns3server/compute/docker/docker_vm.py
@@ -948,7 +948,7 @@ class DockerVM(DockerKernelDatapathMixin, BaseNode):
await self._start_vnc_process(restart=True)
try:
await wait_for_file_creation(x11_socket)
- except asyncio.TimeoutError:
+ except TimeoutError:
raise DockerError(f'x11 socket file "{x11_socket}" does not exist')
monitor_process(self._vnc_process, self._vnc_callback)
@@ -1190,7 +1190,7 @@ class DockerVM(DockerKernelDatapathMixin, BaseNode):
return False
try:
_, stderr = await asyncio.wait_for(process.communicate(), timeout=60)
- except asyncio.TimeoutError:
+ except TimeoutError:
process.kill()
await process.communicate()
log.warning(f"Docker container '{self._name}': reclaiming '{directory}' timed out")
@@ -1254,7 +1254,7 @@ class DockerVM(DockerKernelDatapathMixin, BaseNode):
x11_socket = os.path.join("/tmp/.X11-unix/", f"X{self._display}")
try:
await wait_for_file_creation(x11_socket)
- except asyncio.TimeoutError:
+ except TimeoutError:
raise DockerError(f'x11 socket file "{x11_socket}" does not exist')
if not hasattr(sys, "_called_from_test") or not sys._called_from_test:
@@ -1711,15 +1711,7 @@ class DockerVM(DockerKernelDatapathMixin, BaseNode):
status_line = headers.split(b"\r\n", 1)[0]
if b" 101 " not in status_line and b" 200 " not in status_line:
raise DockerError(f"Docker interface monitor was rejected: {status_line.decode(errors='ignore')}")
- except (
- DockerError,
- OSError,
- KeyError,
- TypeError,
- RuntimeError,
- asyncio.IncompleteReadError,
- asyncio.TimeoutError,
- ) as e:
+ except (TimeoutError, DockerError, OSError, KeyError, TypeError, RuntimeError, asyncio.IncompleteReadError) as e:
if "writer" in locals():
await self._close_interface_monitor_writer(writer)
log.warning("Could not monitor interfaces for Docker container '%s': %s", self.name, e)
diff --git a/gns3server/compute/docker/vendor_docker_vm.py b/gns3server/compute/docker/vendor_docker_vm.py
index 3daa935e5..9601a4d06 100644
--- a/gns3server/compute/docker/vendor_docker_vm.py
+++ b/gns3server/compute/docker/vendor_docker_vm.py
@@ -459,7 +459,7 @@ class VendorDockerVM(DockerVM):
# setup; wait instead of silently blackholing the adapter.
try:
await wait_for_file_creation(remote_sock, timeout=30)
- except asyncio.TimeoutError:
+ except TimeoutError:
raise DockerError(
f"Socket '{remote_sock}' for adapter {adapter_number} of container "
f"'{self._name}' did not appear within 30 seconds. Check that the "
@@ -806,7 +806,7 @@ class _LazyExecTelnetServer(AsyncioTelnetServer):
await writer.drain()
try:
headers = await asyncio.wait_for(reader.readuntil(b"\r\n\r\n"), timeout=5)
- except (asyncio.IncompleteReadError, asyncio.TimeoutError) as e:
+ except (TimeoutError, asyncio.IncompleteReadError) as e:
writer.close()
raise DockerError(f"Docker exec start failed: {e}")
status_line = headers.split(b"\r\n", 1)[0]
diff --git a/gns3server/compute/dynamips/dynamips_hypervisor.py b/gns3server/compute/dynamips/dynamips_hypervisor.py
index 11f80221d..44648ef95 100644
--- a/gns3server/compute/dynamips/dynamips_hypervisor.py
+++ b/gns3server/compute/dynamips/dynamips_hypervisor.py
@@ -80,7 +80,7 @@ class DynamipsHypervisor:
self._reader, self._writer = await asyncio.wait_for(
asyncio.open_connection(host, self._port), timeout=1
)
- except (asyncio.TimeoutError, OSError) as e:
+ except (TimeoutError, OSError) as e:
last_exception = e
continue
connection_success = True
diff --git a/gns3server/compute/dynamips/hypervisor.py b/gns3server/compute/dynamips/hypervisor.py
index c1d3f5980..d56c81678 100644
--- a/gns3server/compute/dynamips/hypervisor.py
+++ b/gns3server/compute/dynamips/hypervisor.py
@@ -144,7 +144,7 @@ class Hypervisor(DynamipsHypervisor):
await asyncio.sleep(0.01)
try:
await wait_for_process_termination(self._process, timeout=3)
- except asyncio.TimeoutError:
+ except TimeoutError:
if self._process.returncode is None:
log.warning(f"Dynamips process {self._process.pid} is still running... killing it")
try:
diff --git a/gns3server/compute/iou/iou_vm.py b/gns3server/compute/iou/iou_vm.py
index 679050f6f..34b44bb09 100644
--- a/gns3server/compute/iou/iou_vm.py
+++ b/gns3server/compute/iou/iou_vm.py
@@ -1034,7 +1034,7 @@ class IOUVM(KernelDatapathMixin, BaseNode):
if self._iou_process.returncode is None:
try:
await gns3server.utils.asyncio.wait_for_process_termination(self._iou_process, timeout=3)
- except asyncio.TimeoutError:
+ except TimeoutError:
if self._iou_process.returncode is None:
log.warning(f"IOU process {self._iou_process.pid} is still running... killing it")
try:
diff --git a/gns3server/compute/qemu/qemu_vm.py b/gns3server/compute/qemu/qemu_vm.py
index eb2f2eb79..453ec3437 100644
--- a/gns3server/compute/qemu/qemu_vm.py
+++ b/gns3server/compute/qemu/qemu_vm.py
@@ -1272,7 +1272,7 @@ class QemuVM(KernelDatapathMixin, BaseNode):
await gns3server.utils.asyncio.wait_for_process_termination(self._process, timeout=3)
except ProcessLookupError:
pass
- except asyncio.TimeoutError:
+ except TimeoutError:
if self._process:
try:
self._process.kill()
@@ -1324,7 +1324,7 @@ class QemuVM(KernelDatapathMixin, BaseNode):
try:
log.debug(f"Connecting to Qemu monitor on {self._monitor_host}:{self._monitor}")
reader, writer = await asyncio.open_connection(self._monitor_host, self._monitor)
- except (asyncio.TimeoutError, OSError) as e:
+ except (TimeoutError, OSError) as e:
last_exception = e
continue
connection_success = True
@@ -1363,7 +1363,7 @@ class QemuVM(KernelDatapathMixin, BaseNode):
line = await asyncio.wait_for(reader.readline(), timeout=3) # echo of the command
if not line or cmd_byte in line:
break
- except asyncio.TimeoutError:
+ except TimeoutError:
log.warning(f"Missing echo of command '{command}'")
except OSError as e:
log.warning(f"Could not write to QEMU monitor: {e}")
@@ -1379,7 +1379,7 @@ class QemuVM(KernelDatapathMixin, BaseNode):
if expect in line:
result = line.decode("utf-8").strip()
break
- except asyncio.TimeoutError:
+ except TimeoutError:
log.warning(f"Timeout while waiting for result of command '{command}'")
except (ConnectionError, EOFError) as e:
log.warning(f"Could not read from QEMU monitor: {e}")
@@ -1407,7 +1407,7 @@ class QemuVM(KernelDatapathMixin, BaseNode):
line = await asyncio.wait_for(reader.readline(), timeout=3) # echo of the command
if not line or cmd_byte in line:
break
- except asyncio.TimeoutError:
+ except TimeoutError:
log.warning(f"Missing echo of command '{command}'")
except OSError as e:
log.warning(f"Could not write to QEMU monitor: {e}")
diff --git a/gns3server/compute/ubridge/hypervisor.py b/gns3server/compute/ubridge/hypervisor.py
index 66dddd99a..8a7b78090 100644
--- a/gns3server/compute/ubridge/hypervisor.py
+++ b/gns3server/compute/ubridge/hypervisor.py
@@ -230,7 +230,7 @@ class Hypervisor(UBridgeHypervisor):
await UBridgeHypervisor.stop(self)
try:
await wait_for_process_termination(self._process, timeout=3)
- except asyncio.TimeoutError:
+ except TimeoutError:
if self._process and self._process.returncode is None:
log.warning(f"uBridge process {self._process.pid} is still running... killing it")
try:
diff --git a/gns3server/compute/ubridge/tc_probe.py b/gns3server/compute/ubridge/tc_probe.py
index 4322a53ee..f8b9c5b26 100644
--- a/gns3server/compute/ubridge/tc_probe.py
+++ b/gns3server/compute/ubridge/tc_probe.py
@@ -112,7 +112,7 @@ async def _probe(path, config, timeout):
try:
caps = await asyncio.wait_for(ask(), timeout=timeout)
- except (UbridgeError, OSError, asyncio.TimeoutError, ValueError) as e:
+ except (TimeoutError, UbridgeError, OSError, ValueError) as e:
# Old uBridge builds answer "Unknown command"/"Unknown module";
# anything else here is a broken install — either way: unknown.
log.debug("uBridge tc capabilities probe failed: %s", e)
@@ -183,7 +183,7 @@ async def _probe_tap(path, config, timeout):
try:
return await asyncio.wait_for(ask(), timeout=timeout)
- except (UbridgeError, OSError, asyncio.TimeoutError, ValueError) as e:
+ except (TimeoutError, UbridgeError, OSError, ValueError) as e:
# Missing module, old build, or no CAP_NET_ADMIN: unknown.
log.debug("uBridge tap-module probe failed: %s", e)
return None
@@ -269,7 +269,7 @@ async def _probe_iol_tap(path, config, timeout):
try:
return await asyncio.wait_for(ask(), timeout=timeout)
- except (UbridgeError, OSError, asyncio.TimeoutError, ValueError) as e:
+ except (TimeoutError, UbridgeError, OSError, ValueError) as e:
# Old build ("Unknown command"), missing module, or no
# CAP_NET_ADMIN: unknown.
log.debug("uBridge iol-tap probe failed: %s", e)
@@ -348,7 +348,7 @@ async def _probe_bridge_tap(path, config, timeout):
try:
return await asyncio.wait_for(ask(), timeout=timeout)
- except (UbridgeError, OSError, asyncio.TimeoutError, ValueError) as e:
+ except (TimeoutError, UbridgeError, OSError, ValueError) as e:
# UbridgeError also covers hypervisor.start()/connect() failing
# (unlike the siblings, ask() re-raises those): an unusable
# binary means unknown, never a failed /capabilities response.
diff --git a/gns3server/compute/virtualbox/__init__.py b/gns3server/compute/virtualbox/__init__.py
index 27313318f..78c15d5fc 100644
--- a/gns3server/compute/virtualbox/__init__.py
+++ b/gns3server/compute/virtualbox/__init__.py
@@ -112,7 +112,7 @@ class VirtualBox(BaseManager):
try:
stdout_data, stderr_data = await asyncio.wait_for(process.communicate(), timeout=timeout)
- except asyncio.TimeoutError:
+ except TimeoutError:
raise VirtualBoxError(f"VBoxManage has timed out after {timeout} seconds!")
if process.returncode:
diff --git a/gns3server/compute/vmware/__init__.py b/gns3server/compute/vmware/__init__.py
index cc480688e..d521b6415 100644
--- a/gns3server/compute/vmware/__init__.py
+++ b/gns3server/compute/vmware/__init__.py
@@ -382,7 +382,7 @@ class VMware(BaseManager):
try:
stdout_data, _ = await asyncio.wait_for(process.communicate(), timeout=timeout)
- except asyncio.TimeoutError:
+ except TimeoutError:
raise VMwareError(
f"vmrun has timed out after {timeout} seconds!\nTry to run {command_string} in a terminal to see more details.\n\nMake sure GNS3 and VMware run under the same user and whitelist vmrun.exe in your antivirus."
)
diff --git a/gns3server/compute/vpcs/vpcs_probe.py b/gns3server/compute/vpcs/vpcs_probe.py
index 695a6ff63..af5c3a0f9 100644
--- a/gns3server/compute/vpcs/vpcs_probe.py
+++ b/gns3server/compute/vpcs/vpcs_probe.py
@@ -83,7 +83,7 @@ async def probe_vpcs_tap(timeout: float = 5.0) -> bool | None:
return _cache[key]
try:
output = await asyncio.wait_for(subprocess_check_output(vpcs_path, "-h"), timeout=timeout)
- except (OSError, asyncio.TimeoutError, ValueError) as e:
+ except (TimeoutError, OSError, ValueError) as e:
log.debug("VPCS tap-mode probe failed: %s", e)
supported = None
else:
diff --git a/gns3server/compute/vpcs/vpcs_vm.py b/gns3server/compute/vpcs/vpcs_vm.py
index df9c31ab1..536aef70e 100644
--- a/gns3server/compute/vpcs/vpcs_vm.py
+++ b/gns3server/compute/vpcs/vpcs_vm.py
@@ -333,7 +333,7 @@ class VPCSVM(KernelDatapathMixin, BaseNode):
if self._process.returncode is None:
try:
await wait_for_process_termination(self._process, timeout=3)
- except asyncio.TimeoutError:
+ except TimeoutError:
if self._process.returncode is None:
try:
self._process.kill()
diff --git a/gns3server/controller/appliance_manager.py b/gns3server/controller/appliance_manager.py
index f4ecdded5..338bc2615 100644
--- a/gns3server/controller/appliance_manager.py
+++ b/gns3server/controller/appliance_manager.py
@@ -15,7 +15,6 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
-import asyncio
import copy
import json
import logging
@@ -221,7 +220,7 @@ class ApplianceManager:
raise ControllerError(f"Could not save {image_type} image '{image_path}': {e}")
except ClientError as e:
raise ControllerError(f"Could not connect to download '{image_name}': {e}")
- except asyncio.TimeoutError:
+ except TimeoutError:
raise ControllerError(f"Timeout while downloading '{image_name}' from '{image_url}'")
async def _find_appliance_version_images(
@@ -551,7 +550,7 @@ class ApplianceManager:
log.info(f"Saving {symbol} symbol to {destination_path}")
with open(destination_path, "wb") as f:
f.write(symbol_data)
- except asyncio.TimeoutError:
+ except TimeoutError:
log.warning(f"Timeout while downloading '{symbol_url}'")
except OSError as e:
log.warning(f"Could not write appliance symbol '{destination_path}': {e}")
@@ -601,7 +600,7 @@ class ApplianceManager:
continue
try:
appliance_data = await response.read()
- except asyncio.TimeoutError:
+ except TimeoutError:
log.warning("Timeout while downloading '{}'".format(appliance["download_url"]))
continue
path = os.path.join(appliances_dir, appliance_name)
diff --git a/gns3server/controller/compute.py b/gns3server/controller/compute.py
index aa2095eca..29ba10e31 100644
--- a/gns3server/controller/compute.py
+++ b/gns3server/controller/compute.py
@@ -635,7 +635,7 @@ class Compute:
chunked=chunked,
timeout=timeout,
)
- except asyncio.TimeoutError:
+ except TimeoutError:
raise ComputeError(f"Timeout error for {method} call to {url} after {timeout}s")
except (
aiohttp.ClientError,
diff --git a/gns3server/controller/export_project.py b/gns3server/controller/export_project.py
index f70da2537..a0e3de407 100644
--- a/gns3server/controller/export_project.py
+++ b/gns3server/controller/export_project.py
@@ -15,7 +15,6 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
-import asyncio
import json
import logging
import os
@@ -134,7 +133,7 @@ async def export_project(
while True:
try:
data = await response.content.read(CHUNK_SIZE)
- except asyncio.TimeoutError:
+ except TimeoutError:
raise ControllerTimeoutError(
"Timeout when downloading file '{}' from remote compute {}:{}".format(
compute_file["path"], compute.host, compute.port
@@ -326,7 +325,7 @@ async def _export_remote_images(project, compute_id, image_type, image, project_
while True:
try:
data = await response.content.read(CHUNK_SIZE)
- except asyncio.TimeoutError:
+ except TimeoutError:
raise ControllerTimeoutError(
f"Timeout when downloading image '{image}' from remote compute {compute.host}:{compute.port}"
)
diff --git a/gns3server/controller/gns3vm/virtualbox_gns3_vm.py b/gns3server/controller/gns3vm/virtualbox_gns3_vm.py
index fe39b3dd3..a643e1567 100644
--- a/gns3server/controller/gns3vm/virtualbox_gns3_vm.py
+++ b/gns3server/controller/gns3vm/virtualbox_gns3_vm.py
@@ -434,7 +434,7 @@ class VirtualBoxGNS3VM(BaseGNS3VM):
return interface["ip_address"]
except ValueError:
pass
- except (OSError, aiohttp.ClientError, TimeoutError, asyncio.TimeoutError):
+ except (OSError, aiohttp.ClientError, TimeoutError):
pass
remaining_try -= 1
await asyncio.sleep(1)
diff --git a/gns3server/controller/marker_replay.py b/gns3server/controller/marker_replay.py
index 716c5cf82..cb55d4cf5 100644
--- a/gns3server/controller/marker_replay.py
+++ b/gns3server/controller/marker_replay.py
@@ -349,7 +349,7 @@ class _SharkdSession:
self.proc.stdin.write((json.dumps(request) + "\n").encode())
await self.proc.stdin.drain()
raw = await asyncio.wait_for(self.proc.stdout.readline(), RPC_TIMEOUT_SECONDS)
- except asyncio.TimeoutError:
+ except TimeoutError:
await self._abort(f"sharkd timed out after {RPC_TIMEOUT_SECONDS:.0f}s on {method!r}")
except (OSError, ValueError) as e:
# ValueError: a reply line over the StreamReader limit — the
@@ -387,7 +387,7 @@ class _SharkdSession:
# the caller — leak the process with a log instead.
try:
await asyncio.wait_for(self.proc.wait(), timeout=2.0)
- except asyncio.TimeoutError:
+ except TimeoutError:
log.warning("sharkd session for %s did not exit after kill", self.pcap)
except ProcessLookupError:
pass
diff --git a/gns3server/controller/node.py b/gns3server/controller/node.py
index fb36ee8ef..643649d7e 100644
--- a/gns3server/controller/node.py
+++ b/gns3server/controller/node.py
@@ -965,7 +965,7 @@ class Node:
)
else:
await self.post("/start", data=data, timeout=240)
- except asyncio.TimeoutError:
+ except TimeoutError:
raise ControllerTimeoutError(f"Timeout when starting {self._name}")
self._confirm_status("started")
# A started node may have brought kernel anchors into existence that
@@ -990,7 +990,7 @@ class Node:
# We don't care if a node is down at this step
if strict:
raise
- except asyncio.TimeoutError:
+ except TimeoutError:
raise ControllerTimeoutError(f"Timeout when stopping {self._name}")
if stopped:
self._confirm_status("stopped")
@@ -1015,7 +1015,7 @@ class Node:
"""
try:
await self.post("/suspend", timeout=240)
- except asyncio.TimeoutError:
+ except TimeoutError:
raise ControllerTimeoutError(f"Timeout when suspending {self._name}")
self._confirm_status("suspended")
@@ -1025,7 +1025,7 @@ class Node:
"""
try:
await self.post("/reload", timeout=240)
- except asyncio.TimeoutError:
+ except TimeoutError:
raise ControllerTimeoutError(f"Timeout when reloading {self._name}")
self._confirm_status("started")
@@ -1037,7 +1037,7 @@ class Node:
if self._console and self._console_type in ("telnet", "ssh"):
try:
await self.post("/console/reset", timeout=240)
- except asyncio.TimeoutError:
+ except TimeoutError:
raise ControllerTimeoutError(f"Timeout when reset console {self._name}")
async def get(self, path="", **kwargs):
diff --git a/gns3server/controller/snapshot.py b/gns3server/controller/snapshot.py
index 811db0fde..b7d615d76 100644
--- a/gns3server/controller/snapshot.py
+++ b/gns3server/controller/snapshot.py
@@ -23,7 +23,7 @@ import tempfile
import time
import uuid
import zipfile
-from datetime import datetime, timezone
+from datetime import UTC, datetime
import aiofiles
@@ -63,19 +63,19 @@ class Snapshot:
if created_at:
self._created_at = created_at
else:
- self._created_at = int(datetime.now(timezone.utc).timestamp())
+ self._created_at = int(datetime.now(UTC).timestamp())
if not filename:
filename = self._name + ".gns3snapshot"
else:
self._name = filename.rsplit("_", 2)[0]
datestring = filename.replace(self._name + "_", "").split(".")[0]
self._created_at = int(
- datetime.strptime(datestring, FILENAME_DATETIME_FORMAT).replace(tzinfo=timezone.utc).timestamp()
+ datetime.strptime(datestring, FILENAME_DATETIME_FORMAT).replace(tzinfo=UTC).timestamp()
)
if not description:
date = (
- datetime.fromtimestamp(self._created_at, tz=timezone.utc)
+ datetime.fromtimestamp(self._created_at, tz=UTC)
.replace(tzinfo=None)
.strftime(DESCRIPTION_DATETIME_FORMAT)
)
diff --git a/gns3server/db/repositories/images.py b/gns3server/db/repositories/images.py
index 90d5f601b..639c8f2e6 100644
--- a/gns3server/db/repositories/images.py
+++ b/gns3server/db/repositories/images.py
@@ -18,7 +18,7 @@
import asyncio
import logging
import os
-from datetime import datetime, timezone
+from datetime import UTC, datetime
from typing import Callable, List, Optional, cast
from sqlalchemy import delete, select, update
@@ -166,8 +166,8 @@ class ImagesRepository(BaseRepository):
values.update(
availability="available",
last_error=None,
- last_seen_at=datetime.now(timezone.utc).replace(tzinfo=None),
- last_verified_at=datetime.now(timezone.utc).replace(tzinfo=None),
+ last_seen_at=datetime.now(UTC).replace(tzinfo=None),
+ last_verified_at=datetime.now(UTC).replace(tzinfo=None),
)
for attempt in range(2):
try:
diff --git a/gns3server/schemas/controller/snapshots.py b/gns3server/schemas/controller/snapshots.py
index d86fd21aa..adbb7b726 100644
--- a/gns3server/schemas/controller/snapshots.py
+++ b/gns3server/schemas/controller/snapshots.py
@@ -15,7 +15,7 @@
# along with this program. If not, see .
-from datetime import datetime, timezone
+from datetime import UTC, datetime
from typing import Optional
from uuid import UUID
@@ -54,5 +54,5 @@ class Snapshot(SnapshotBase):
@classmethod
def _derive_created(cls, data):
if isinstance(data, dict) and "created" not in data and data.get("created_at") is not None:
- data = {**data, "created": datetime.fromtimestamp(data["created_at"], tz=timezone.utc)}
+ data = {**data, "created": datetime.fromtimestamp(data["created_at"], tz=UTC)}
return data
diff --git a/gns3server/services/authentication.py b/gns3server/services/authentication.py
index d4d6f6b79..6652439cb 100644
--- a/gns3server/services/authentication.py
+++ b/gns3server/services/authentication.py
@@ -18,7 +18,7 @@ import base64
import json
import logging
import time
-from datetime import datetime, timedelta, timezone
+from datetime import UTC, datetime, timedelta
from typing import Optional
import bcrypt
@@ -64,7 +64,7 @@ class AuthService:
def _create_token(self, username, token_version, token_type, expires_in, secret_key=None) -> str:
"""Shared helper to create any kind of signed JWT token."""
- issued_at = datetime.now(timezone.utc)
+ issued_at = datetime.now(UTC)
expire = issued_at + timedelta(minutes=expires_in)
to_encode = {"sub": username, "iat": issued_at, "exp": expire, "ver": token_version, "type": token_type}
if secret_key is None:
diff --git a/gns3server/services/image_reconciliation.py b/gns3server/services/image_reconciliation.py
index 6fac6bb3f..5411d6992 100644
--- a/gns3server/services/image_reconciliation.py
+++ b/gns3server/services/image_reconciliation.py
@@ -6,7 +6,7 @@ import os
import stat
import threading
import uuid
-from datetime import datetime, timezone
+from datetime import UTC, datetime
from sqlalchemy import delete, select, update
from sqlalchemy.ext.asyncio import AsyncSession
@@ -44,7 +44,7 @@ RAW_EXTENSIONS = {".raw", ".img", ".iso", ".fd", ".vhd", ".vdi", ".bin"}
def utcnow():
- return datetime.now(timezone.utc).replace(tzinfo=None)
+ return datetime.now(UTC).replace(tzinfo=None)
def ignored(name):
@@ -476,7 +476,7 @@ class ImageReconciliationService:
try:
await asyncio.wait_for(self.dirty.wait(), Config.instance().settings.Server.image_sync_interval)
await asyncio.sleep(1) # debounce bursts of file/directory events
- except asyncio.TimeoutError:
+ except TimeoutError:
pass
except asyncio.CancelledError:
break
diff --git a/gns3server/utils/asyncio/__init__.py b/gns3server/utils/asyncio/__init__.py
index 98b72c66b..a1abc9e10 100644
--- a/gns3server/utils/asyncio/__init__.py
+++ b/gns3server/utils/asyncio/__init__.py
@@ -125,7 +125,7 @@ async def wait_for_file_creation(path, timeout=60):
return
await asyncio.sleep(0.5)
timeout -= 0.5
- raise asyncio.TimeoutError()
+ raise TimeoutError()
def locking(f):
diff --git a/gns3server/utils/asyncio/serial.py b/gns3server/utils/asyncio/serial.py
index 8a20a0799..22c2e5690 100644
--- a/gns3server/utils/asyncio/serial.py
+++ b/gns3server/utils/asyncio/serial.py
@@ -66,7 +66,7 @@ async def _asyncio_open_serial_unix(path):
try:
# wait for VM to create the pipe file.
await wait_for_file_creation(path)
- except asyncio.TimeoutError:
+ except TimeoutError:
raise NodeError(f'Pipe file "{path}" is missing')
output = SerialReaderWriterProtocol()
diff --git a/gns3server/utils/asyncio/ssh_server.py b/gns3server/utils/asyncio/ssh_server.py
index 3064b729d..b67252a99 100644
--- a/gns3server/utils/asyncio/ssh_server.py
+++ b/gns3server/utils/asyncio/ssh_server.py
@@ -147,7 +147,7 @@ class AsyncioSSHServer:
try:
process.stdout.write(data)
await asyncio.wait_for(process.stdout.drain(), timeout=BROADCAST_DRAIN_TIMEOUT)
- except (OSError, ConnectionError, asyncio.TimeoutError, asyncssh.Error):
+ except (TimeoutError, OSError, ConnectionError, asyncssh.Error):
await self._disconnect_client(process)
except asyncio.CancelledError:
raise
diff --git a/gns3server/utils/asyncio/telnet_server.py b/gns3server/utils/asyncio/telnet_server.py
index 8cc248687..20d72e755 100644
--- a/gns3server/utils/asyncio/telnet_server.py
+++ b/gns3server/utils/asyncio/telnet_server.py
@@ -324,7 +324,7 @@ class AsyncioTelnetServer:
try:
connection.writer.write(data)
await asyncio.wait_for(connection.writer.drain(), timeout=BROADCAST_DRAIN_TIMEOUT)
- except (OSError, ConnectionError, asyncio.TimeoutError) as e:
+ except (TimeoutError, OSError, ConnectionError) as e:
client_info = self._get_peername(network_writer)
log.debug(
"Error sending data to client %s: %s, closing and removing from connection table.",
@@ -352,7 +352,7 @@ class AsyncioTelnetServer:
log.debug("Sending keepalive to client %s", client_info)
connection.writer.send_iac(IAC + NOP)
await asyncio.wait_for(connection.writer.drain(), timeout=BROADCAST_DRAIN_TIMEOUT)
- except (OSError, ConnectionError, asyncio.TimeoutError) as e:
+ except (TimeoutError, OSError, ConnectionError) as e:
log.debug(
"Keepalive failed for client %s: %s, closing connection.",
client_info,
diff --git a/gns3server/utils/notification_queue.py b/gns3server/utils/notification_queue.py
index 4c0e0d6a4..fcbe4c221 100644
--- a/gns3server/utils/notification_queue.py
+++ b/gns3server/utils/notification_queue.py
@@ -59,7 +59,7 @@ class NotificationQueue(asyncio.Queue):
try:
(action, msg, kwargs) = await asyncio.wait_for(super().get(), timeout - (now - self._last_ping))
return (action, msg, kwargs)
- except asyncio.TimeoutError:
+ except TimeoutError:
continue # the ping deadline has been reached
def _ping(self):
diff --git a/tests/api/routes/controller/test_snapshots.py b/tests/api/routes/controller/test_snapshots.py
index aeff6d9f9..d4180a562 100644
--- a/tests/api/routes/controller/test_snapshots.py
+++ b/tests/api/routes/controller/test_snapshots.py
@@ -17,7 +17,7 @@
import os
import uuid
-from datetime import datetime, timezone
+from datetime import UTC, datetime
import pytest
import pytest_asyncio
@@ -57,7 +57,7 @@ class TestSnapshotRoutes:
assert len(response.json()) == 1
data = response.json()[0]
assert isinstance(data["created_at"], int)
- assert datetime.fromisoformat(data["created"]) == datetime.fromtimestamp(data["created_at"], tz=timezone.utc)
+ assert datetime.fromisoformat(data["created"]) == datetime.fromtimestamp(data["created_at"], tz=UTC)
async def test_delete_snapshot(
self, app: FastAPI, client: AsyncClient, project: Project, snapshot: Snapshot
@@ -86,7 +86,7 @@ class TestSnapshotRoutes:
assert len(os.listdir(os.path.join(project.path, "snapshots"))) == 2
data = response.json()
assert isinstance(data["created_at"], int)
- assert datetime.fromisoformat(data["created"]) == datetime.fromtimestamp(data["created_at"], tz=timezone.utc)
+ assert datetime.fromisoformat(data["created"]) == datetime.fromtimestamp(data["created_at"], tz=UTC)
async def test_snapshot_schema_timestamps(self, app: FastAPI) -> None:
diff --git a/tests/compute/docker/test_docker.py b/tests/compute/docker/test_docker.py
index 5905c30ea..7fe316f67 100644
--- a/tests/compute/docker/test_docker.py
+++ b/tests/compute/docker/test_docker.py
@@ -239,7 +239,7 @@ async def test_pull_image_propagates_timeout():
class Content:
async def read(self, size):
- raise asyncio.TimeoutError
+ raise TimeoutError
response = MagicMock()
response.content = Content()
diff --git a/tests/compute/docker/test_iol_docker_vm.py b/tests/compute/docker/test_iol_docker_vm.py
index 49b1952b5..05cddfef7 100644
--- a/tests/compute/docker/test_iol_docker_vm.py
+++ b/tests/compute/docker/test_iol_docker_vm.py
@@ -22,7 +22,6 @@ Image-free: everything is asserted against generated files, parsed knobs and
the uBridge command stream.
"""
-import asyncio
import glob
import json
import os
@@ -454,7 +453,7 @@ async def test_add_ubridge_connection_timeout_is_actionable(compute_project, man
vm._stop_ubridge = AsyncioMagicMock()
async def raise_timeout(path, timeout=60):
- raise asyncio.TimeoutError()
+ raise TimeoutError()
with patch("gns3server.compute.docker.vendor_docker_vm.wait_for_file_creation", side_effect=raise_timeout):
with pytest.raises(DockerError) as excinfo:
diff --git a/tests/services/test_image_reconciliation.py b/tests/services/test_image_reconciliation.py
index 47beef1b6..57611b66b 100644
--- a/tests/services/test_image_reconciliation.py
+++ b/tests/services/test_image_reconciliation.py
@@ -586,7 +586,7 @@ async def test_periodic_scan_recovers_without_watcher_events(inventory, config):
# Consume/close the unused Event.wait coroutine, then simulate a timeout.
args[0].close()
await real_sleep(0.01)
- raise asyncio.TimeoutError
+ raise TimeoutError
with (
patch.object(inventory, "_watch", new=AsyncMock()),
diff --git a/tests/stress/telnet_race_condition_test.py b/tests/stress/telnet_race_condition_test.py
index be996cc4b..88e862a7b 100644
--- a/tests/stress/telnet_race_condition_test.py
+++ b/tests/stress/telnet_race_condition_test.py
@@ -72,7 +72,7 @@ class TelnetClient:
response = data.decode("utf-8", errors="ignore")
log.debug(f"Client {self.client_id}: Received: {response[:50]}...")
return response
- except asyncio.TimeoutError:
+ except TimeoutError:
log.debug(f"Client {self.client_id}: No response (timeout)")
except Exception as e:
log.debug(f"Client {self.client_id}: Receive error: {e}")