You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
One situation where this occurs is when a Monitor is started to show instrument parameters. Since it's not a daemon thread, no instrument connections are actually closed upon exiting the interpreter. This can cause issues such as not being able to connect to instruments the next try.
Steps to reproduce
A minimal example is the following:
defsave_file():
withopen('output_file.txt', 'w') asoutfile:
outfile.write('Successfully terminated and called exit function')
importatexitatexit.register(save_file)
importthreadingthreading.Thread(target=sleep, args=(60,))
If you exit the interpreter within 60 seconds of executing this code, the thread is still running and so the file output_file.txt is never created.
Proposed solution
A solution to this problem is making the Monitor a daemon thread. It should be ensured that this thread does realize when the interpreter is closed, in which case it should terminate itself.
The text was updated successfully, but these errors were encountered:
The qcodes
__init__.py
file contains the following lines (116-120):This is meant to ensure that all instrument connections are terminated once the interpreter closes.
However, if a non-daemon thread is initialized, the registered
atexit
functions are never called. This is a known issue, see e.g. https://stackoverflow.com/questions/58910372/script-stuck-on-exit-when-using-atexit-to-terminate-threads and https://stackoverflow.com/questions/3713360/python-2-6-x-theading-signals-atexit-fail-on-some-versionsOne situation where this occurs is when a
Monitor
is started to show instrument parameters. Since it's not a daemon thread, no instrument connections are actually closed upon exiting the interpreter. This can cause issues such as not being able to connect to instruments the next try.Steps to reproduce
A minimal example is the following:
If you exit the interpreter within 60 seconds of executing this code, the thread is still running and so the file
output_file.txt
is never created.Proposed solution
A solution to this problem is making the
Monitor
a daemon thread. It should be ensured that this thread does realize when the interpreter is closed, in which case it should terminate itself.The text was updated successfully, but these errors were encountered: