-
Notifications
You must be signed in to change notification settings - Fork 320
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: protect threading users against clutter (#771)
- Loading branch information
1 parent
ad4a3ee
commit 0435245
Showing
2 changed files
with
54 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import gc | ||
|
||
from unittest import TestCase | ||
|
||
from qcodes import Loop | ||
from qcodes.actions import UnsafeThreadingException | ||
from qcodes.tests.instrument_mocks import DummyInstrument | ||
|
||
|
||
class TestUnsafeThreading(TestCase): | ||
|
||
def setUp(self): | ||
self.inst1 = DummyInstrument(name='inst1', | ||
gates=['v1', 'v2']) | ||
self.inst2 = DummyInstrument(name='inst2', | ||
gates=['v1', 'v2']) | ||
|
||
def tearDown(self): | ||
self.inst1.close() | ||
self.inst2.close() | ||
|
||
del self.inst1 | ||
del self.inst2 | ||
|
||
gc.collect() | ||
|
||
def test_unsafe_exception(self): | ||
to_meas = (self.inst1.v1, self.inst1.v2) | ||
loop = Loop(self.inst2.v1.sweep(0, 1, num=10)).each(*to_meas) | ||
|
||
with self.assertRaises(UnsafeThreadingException): | ||
loop.run(use_threads=True) |