1 file changed
+2
-0
lines changedDiff for: artiq/test/hardware_testbench.py
+2
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
27 | 27 |
| |
28 | 28 |
| |
29 | 29 |
| |
| 30 | + | |
| 31 | + | |
30 | 32 |
| |
31 | 33 |
| |
32 | 34 |
| |
|
artiq/test/hardware_testbench.py
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
27 | 27 |
| |
28 | 28 |
| |
29 | 29 |
| |
| 30 | + | |
| 31 | + | |
30 | 32 |
| |
31 | 33 |
| |
32 | 34 |
| |
|
6 commit comments
sbourdeauducq commentedon Jan 31, 2016
What does this do?
artiq/artiq/test/hardware_testbench.py
Line 49 in d05d720
sbourdeauducq commentedon Jan 31, 2016
Do not use
terminate
on Python process objects, it is not portable. The only things that are portable are:kill
method of process objectsYou should put this RPC termination request into
stop_controller
, to replaceproc.terminate
.jordens commentedon Jan 31, 2016
On the contrary: both
terminate()
andkill()
are portable. Just on windowskill()
is an alias ofterminate()
.sbourdeauducq commentedon Jan 31, 2016
It is not portable, they do different things.
terminate
sends a signal that can be caught on Unix and cannot on Windows.The correct way to terminate a process in ARTIQ is request termination via IPC/RPC, wait, and kill on timeout. This is not what your code does.
On Linux, it requests termination then immediately sends a signal to the process that is in general not caught (signal implementations in Python are racy so let's not touch them) and therefore will cause ungraceful termination, waits, and kills on timeout.
On Windows, it requests termination then immediately kills without any time for the process to gracefully end. The wait and second kill are useless.
jordens commentedon Jan 31, 2016
But the way to terminate a process on Unix is to SIGTERM and then SIGKILL. Exactly because with SIGTERM the process has the chance to do cleanup. This is not useless on linux and is relevant if the controller is stuck, does not react to
terminate()
, but the underlying driver still reacts to SIGTERM and expects to clean up. If you SIGKILL in that situation will do more harm than good. The following sequence seems to cover both linux and windows and the rpc protocol:sbourdeauducq commentedon Jan 31, 2016
I would make the intent clearer by adding a test for
os.name
that skips theproc.terminate
on Windows and perhaps a source code comment; otherwise okay, preferably this process termination method would be used consistently throughout ARTIQ.