File tree Expand file tree Collapse file tree 1 file changed +9
-0
lines changed
src/qibolab/_core/platform Expand file tree Collapse file tree 1 file changed +9
-0
lines changed Original file line number Diff line number Diff line change 11"""A platform for executing quantum algorithms."""
22
3+ import signal
34from dataclasses import dataclass , field
45from pathlib import Path
56from typing import Literal , Optional
@@ -75,6 +76,8 @@ class Platform:
7576
7677 def __post_init__ (self ):
7778 log .info ("Loading platform %s" , self .name )
79+ signal .signal (signal .SIGTERM , self .termination_handler )
80+ signal .signal (signal .SIGINT , self .termination_handler )
7881 if self .resonator_type is None :
7982 self .resonator_type = "3D" if self .nqubits == 1 else "2D"
8083
@@ -168,6 +171,12 @@ def disconnect(self):
168171 instrument .disconnect ()
169172 self .is_connected = False
170173
174+ def termination_handler (self , signum , frame ):
175+ self .disconnect ()
176+ raise RuntimeError (
177+ f"Platform { self .name } disconnected because job was cancelled. Signal type: { signum } ."
178+ )
179+
171180 @property
172181 def _controller (self ):
173182 """Identify controller instrument.
You can’t perform that action at this time.
0 commit comments