Random test failure in monitor tests in ci (windows)
jenshnielsen opened this issue · 0 comments
jenshnielsen commented
Seen fairly frequently on windows.
=========================== short test summary info ===========================
FAILED qcodes/tests/test_monitor.py::test_setup_teardown - RuntimeError: Fail...
FAILED qcodes/tests/test_monitor.py::test_monitor_replace - RuntimeError: Fai...
FAILED qcodes/tests/test_monitor.py::test_double_join - RuntimeError: Failed ...
FAILED qcodes/tests/test_monitor.py::test_connection - RuntimeError: Failed t...
FAILED qcodes/tests/test_monitor.py::test_use_root_instrument[True] - Runtime...
FAILED qcodes/tests/test_monitor.py::test_use_root_instrument[False] - Runtim...
ERROR qcodes/tests/test_monitor.py::test_parameter - RuntimeError: Failed to ...
=================================== ERRORS ====================================
______________________ ERROR at setup of test_parameter _______________________
[gw1] win32 -- Python 3.10.7 C:\hostedtoolcache\windows\Python\3.10.7\x64\python.exe
@pytest.fixture(name="inst_and_monitor")
def _make_inst_and_monitor():
instr = DummyInstrument("MonitorDummy")
param = Parameter("DummyParam",
unit="V",
get_cmd=None,
set_cmd=None)
param(1)
monitor_parameters = tuple(instr.parameters.values())[1:]
> my_monitor = monitor.Monitor(*monitor_parameters, param, interval=0.1)
qcodes\tests\test_monitor.py:27:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <Monitor(Thread-10, stopped 4404)>, interval = 0.1
use_root_instrument = True
parameters = (<qcodes.parameters.parameter.Parameter: dac1 at 2660446451168>, <qcodes.parameters.parameter.Parameter: dac2 at 26604...ters.parameter.Parameter: dac3 at 2660446451264>, <qcodes.parameters.parameter.Parameter: DummyParam at 2660446442384>)
parameter = <qcodes.parameters.parameter.Parameter: DummyParam at 2660446442384>
def __init__(
self,
*parameters: Parameter,
interval: float = 1,
use_root_instrument: bool = True,
):
"""
Monitor qcodes parameters.
Args:
*parameters: Parameters to monitor.
interval: How often one wants to refresh the values.
use_root_instrument: Defines if parameters are grouped according to
parameter.root_instrument or parameter.instrument
"""
super().__init__()
# Check that all values are valid parameters
for parameter in parameters:
if not isinstance(parameter, Parameter):
raise TypeError(f"We can only monitor QCodes "
f"Parameters, not {type(parameter)}")
self.loop: Optional[asyncio.AbstractEventLoop] = None
self.server: Optional["WebSocketServer"] = None
self._parameters = parameters
self.loop_is_closed = Event()
self.server_is_started = Event()
self.handler = _handler(
parameters, interval=interval, use_root_instrument=use_root_instrument
)
log.debug("Start monitoring thread")
if Monitor.running:
# stop the old server
log.debug("Stopping and restarting server")
Monitor.running.stop()
self.start()
# Wait until the loop is running
self.server_is_started.wait(timeout=5)
if not self.server_is_started.is_set():
> raise RuntimeError("Failed to start server")
E RuntimeError: Failed to start server
qcodes\monitor\monitor.py:189: RuntimeError
----------------------------- Captured log setup ------------------------------
ERROR qcodes.monitor.monitor:monitor.py:208 Server could not be started
Traceback (most recent call last):
File "D:\a\Qcodes\Qcodes\qcodes\monitor\monitor.py", line 202, in run
self.server = self.loop.run_until_complete(server_start)
File "C:\hostedtoolcache\windows\Python\3.10.7\x64\lib\asyncio\base_events.py", line 646, in run_until_complete
return future.result()
File "C:\hostedtoolcache\windows\Python\3.10.7\x64\lib\asyncio\tasks.py", line 650, in _wrap_awaitable
return (yield from awaitable.__await__())
File "C:\hostedtoolcache\windows\Python\3.10.7\x64\lib\site-packages\websockets\legacy\server.py", line 1088, in __await_impl__
server = await self._create_server()
File "C:\hostedtoolcache\windows\Python\3.10.7\x64\lib\asyncio\base_events.py", line 1505, in create_server
raise OSError(err.errno, 'error while attempting '
PermissionError: [Errno 13] error while attempting to bind on address ('127.0.0.1', 5[78](https://github.com/QCoDeS/Qcodes/actions/runs/3217437938/jobs/5260403272#step:8:79)54): an attempt was made to access a socket in a way forbidden by its access permissions
================================== FAILURES ===================================
_____________________________ test_setup_teardown _____________________________
[gw1] win32 -- Python 3.10.7 C:\hostedtoolcache\windows\Python\3.10.7\x64\python.exe
request = <FixtureRequest for <Function test_setup_teardown>>
def test_setup_teardown(request):
"""
Check that monitor starts up and closes correctly
"""
> m = monitor.Monitor()
qcodes\tests\test_monitor.py:49:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <Monitor(Thread-6, stopped 6960)>, interval = 1
use_root_instrument = True, parameters = ()
def __init__(
self,
*parameters: Parameter,
interval: float = 1,
use_root_instrument: bool = True,
):
"""
Monitor qcodes parameters.
Args:
*parameters: Parameters to monitor.
interval: How often one wants to refresh the values.
use_root_instrument: Defines if parameters are grouped according to
parameter.root_instrument or parameter.instrument
"""
super().__init__()
# Check that all values are valid parameters
for parameter in parameters:
if not isinstance(parameter, Parameter):
raise TypeError(f"We can only monitor QCodes "
f"Parameters, not {type(parameter)}")
self.loop: Optional[asyncio.AbstractEventLoop] = None
self.server: Optional["WebSocketServer"] = None
self._parameters = parameters
self.loop_is_closed = Event()
self.server_is_started = Event()
self.handler = _handler(
parameters, interval=interval, use_root_instrument=use_root_instrument
)
log.debug("Start monitoring thread")
if Monitor.running:
# stop the old server
log.debug("Stopping and restarting server")
Monitor.running.stop()
self.start()
# Wait until the loop is running
self.server_is_started.wait(timeout=5)
if not self.server_is_started.is_set():
> raise RuntimeError("Failed to start server")
E RuntimeError: Failed to start server
qcodes\monitor\monitor.py:189: RuntimeError
------------------------------ Captured log call ------------------------------
ERROR qcodes.monitor.monitor:monitor.py:208 Server could not be started
Traceback (most recent call last):
File "D:\a\Qcodes\Qcodes\qcodes\monitor\monitor.py", line 202, in run
self.server = self.loop.run_until_complete(server_start)
File "C:\hostedtoolcache\windows\Python\3.10.7\x64\lib\asyncio\base_events.py", line 646, in run_until_complete
return future.result()
File "C:\hostedtoolcache\windows\Python\3.10.7\x64\lib\asyncio\tasks.py", line 650, in _wrap_awaitable
return (yield from awaitable.__await__())
File "C:\hostedtoolcache\windows\Python\3.10.7\x64\lib\site-packages\websockets\legacy\server.py", line 1088, in __await_impl__
server = await self._create_server()
File "C:\hostedtoolcache\windows\Python\3.10.7\x64\lib\asyncio\base_events.py", line 1505, in create_server
raise OSError(err.errno, 'error while attempting '
PermissionError: [Errno 13] error while attempting to bind on address ('127.0.0.1', 57854): an attempt was made to access a socket in a way forbidden by its access permissions
____________________________ test_monitor_replace _____________________________
[gw1] win32 -- Python 3.10.7 C:\hostedtoolcache\windows\Python\3.10.7\x64\python.exe
request = <FixtureRequest for <Function test_monitor_replace>>
def test_monitor_replace(request):
"""
Check that monitors get correctly replaced
"""
> m = monitor.Monitor()
qcodes\tests\test_monitor.py:65:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <Monitor(Thread-7, stopped 6268)>, interval = 1
use_root_instrument = True, parameters = ()
def __init__(
self,
*parameters: Parameter,
interval: float = 1,
use_root_instrument: bool = True,
):
"""
Monitor qcodes parameters.
Args:
*parameters: Parameters to monitor.
interval: How often one wants to refresh the values.
use_root_instrument: Defines if parameters are grouped according to
parameter.root_instrument or parameter.instrument
"""
super().__init__()
# Check that all values are valid parameters
for parameter in parameters:
if not isinstance(parameter, Parameter):
raise TypeError(f"We can only monitor QCodes "
f"Parameters, not {type(parameter)}")
self.loop: Optional[asyncio.AbstractEventLoop] = None
self.server: Optional["WebSocketServer"] = None
self._parameters = parameters
self.loop_is_closed = Event()
self.server_is_started = Event()
self.handler = _handler(
parameters, interval=interval, use_root_instrument=use_root_instrument
)
log.debug("Start monitoring thread")
if Monitor.running:
# stop the old server
log.debug("Stopping and restarting server")
Monitor.running.stop()
self.start()
# Wait until the loop is running
self.server_is_started.wait(timeout=5)
if not self.server_is_started.is_set():
> raise RuntimeError("Failed to start server")
E RuntimeError: Failed to start server
qcodes\monitor\monitor.py:189: RuntimeError
------------------------------ Captured log call ------------------------------
ERROR qcodes.monitor.monitor:monitor.py:208 Server could not be started
Traceback (most recent call last):
File "D:\a\Qcodes\Qcodes\qcodes\monitor\monitor.py", line 202, in run
self.server = self.loop.run_until_complete(server_start)
File "C:\hostedtoolcache\windows\Python\3.10.7\x64\lib\asyncio\base_events.py", line 646, in run_until_complete
return future.result()
File "C:\hostedtoolcache\windows\Python\3.10.7\x64\lib\asyncio\tasks.py", line 650, in _wrap_awaitable
return (yield from awaitable.__await__())
File "C:\hostedtoolcache\windows\Python\3.10.7\x64\lib\site-packages\websockets\legacy\server.py", line 1088, in __await_impl__
server = await self._create_server()
File "C:\hostedtoolcache\windows\Python\3.10.7\x64\lib\asyncio\base_events.py", line 1505, in create_server
raise OSError(err.errno, 'error while attempting '
PermissionError: [Errno 13] error while attempting to bind on address ('127.0.0.1', 57854): an attempt was made to access a socket in a way forbidden by its access permissions
______________________________ test_double_join _______________________________
[gw1] win32 -- Python 3.10.7 C:\hostedtoolcache\windows\Python\3.10.7\x64\python.exe
request = <FixtureRequest for <Function test_double_join>>
def test_double_join(request):
"""
Check that a double join doesn't cause a hang
"""
> m = monitor.Monitor()
qcodes\tests\test_monitor.py:[81](https://github.com/QCoDeS/Qcodes/actions/runs/3217437938/jobs/5260403272#step:8:82):
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <Monitor(Thread-8, stopped 5024)>, interval = 1
use_root_instrument = True, parameters = ()
def __init__(
self,
*parameters: Parameter,
interval: float = 1,
use_root_instrument: bool = True,
):
"""
Monitor qcodes parameters.
Args:
*parameters: Parameters to monitor.
interval: How often one wants to refresh the values.
use_root_instrument: Defines if parameters are grouped according to
parameter.root_instrument or parameter.instrument
"""
super().__init__()
# Check that all values are valid parameters
for parameter in parameters:
if not isinstance(parameter, Parameter):
raise TypeError(f"We can only monitor QCodes "
f"Parameters, not {type(parameter)}")
self.loop: Optional[asyncio.AbstractEventLoop] = None
self.server: Optional["WebSocketServer"] = None
self._parameters = parameters
self.loop_is_closed = Event()
self.server_is_started = Event()
self.handler = _handler(
parameters, interval=interval, use_root_instrument=use_root_instrument
)
log.debug("Start monitoring thread")
if Monitor.running:
# stop the old server
log.debug("Stopping and restarting server")
Monitor.running.stop()
self.start()
# Wait until the loop is running
self.server_is_started.wait(timeout=5)
if not self.server_is_started.is_set():
> raise RuntimeError("Failed to start server")
E RuntimeError: Failed to start server
qcodes\monitor\monitor.py:189: RuntimeError
------------------------------ Captured log call ------------------------------
ERROR qcodes.monitor.monitor:monitor.py:208 Server could not be started
Traceback (most recent call last):
File "D:\a\Qcodes\Qcodes\qcodes\monitor\monitor.py", line 202, in run
self.server = self.loop.run_until_complete(server_start)
File "C:\hostedtoolcache\windows\Python\3.10.7\x64\lib\asyncio\base_events.py", line 646, in run_until_complete
return future.result()
File "C:\hostedtoolcache\windows\Python\3.10.7\x64\lib\asyncio\tasks.py", line 650, in _wrap_awaitable
return (yield from awaitable.__await__())
File "C:\hostedtoolcache\windows\Python\3.10.7\x64\lib\site-packages\websockets\legacy\server.py", line 1088, in __await_impl__
server = await self._create_server()
File "C:\hostedtoolcache\windows\Python\3.10.7\x64\lib\asyncio\base_events.py", line 1505, in create_server
raise OSError(err.errno, 'error while attempting '
PermissionError: [Errno 13] error while attempting to bind on address ('127.0.0.1', 57854): an attempt was made to access a socket in a way forbidden by its access permissions
_______________________________ test_connection _______________________________
[gw1] win32 -- Python 3.10.7 C:\hostedtoolcache\windows\Python\3.10.7\x64\python.exe
request = <FixtureRequest for <Function test_connection>>
def test_connection(request):
"""
Test that we can connect to a monitor instance
"""
> m = monitor.Monitor()
qcodes\tests\test_monitor.py:92:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <Monitor(Thread-9, stopped 1492)>, interval = 1
use_root_instrument = True, parameters = ()
def __init__(
self,
*parameters: Parameter,
interval: float = 1,
use_root_instrument: bool = True,
):
"""
Monitor qcodes parameters.
Args:
*parameters: Parameters to monitor.
interval: How often one wants to refresh the values.
use_root_instrument: Defines if parameters are grouped according to
parameter.root_instrument or parameter.instrument
"""
super().__init__()
# Check that all values are valid parameters
for parameter in parameters:
if not isinstance(parameter, Parameter):
raise TypeError(f"We can only monitor QCodes "
f"Parameters, not {type(parameter)}")
self.loop: Optional[asyncio.AbstractEventLoop] = None
self.server: Optional["WebSocketServer"] = None
self._parameters = parameters
self.loop_is_closed = Event()
NoTagError: `git describe` could not find a tag
self.server_is_started = Event()
self.handler = _handler(
parameters, interval=interval, use_root_instrument=use_root_instrument
)
log.debug("Start monitoring thread")
if Monitor.running:
# stop the old server
log.debug("Stopping and restarting server")
Monitor.running.stop()
self.start()
# Wait until the loop is running
self.server_is_started.wait(timeout=5)
if not self.server_is_started.is_set():
> raise RuntimeError("Failed to start server")
E RuntimeError: Failed to start server
qcodes\monitor\monitor.py:189: RuntimeError
------------------------------ Captured log call ------------------------------
ERROR qcodes.monitor.monitor:monitor.py:208 Server could not be started
Traceback (most recent call last):
File "D:\a\Qcodes\Qcodes\qcodes\monitor\monitor.py", line 202, in run
self.server = self.loop.run_until_complete(server_start)
File "C:\hostedtoolcache\windows\Python\3.10.7\x64\lib\asyncio\base_events.py", line 646, in run_until_complete
return future.result()
File "C:\hostedtoolcache\windows\Python\3.10.7\x64\lib\asyncio\tasks.py", line 650, in _wrap_awaitable
return (yield from awaitable.__await__())
File "C:\hostedtoolcache\windows\Python\3.10.7\x64\lib\site-packages\websockets\legacy\server.py", line 1088, in __await_impl__
server = await self._create_server()
File "C:\hostedtoolcache\windows\Python\3.10.7\x64\lib\asyncio\base_events.py", line 1505, in create_server
raise OSError(err.errno, 'error while attempting '
PermissionError: [Errno 13] error while attempting to bind on address ('127.0.0.1', 57854): an attempt was made to access a socket in a way forbidden by its access permissions
_______________________ test_use_root_instrument[True] ________________________
[gw1] win32 -- Python 3.10.7 C:\hostedtoolcache\windows\Python\3.10.7\x64\python.exe
request = <FixtureRequest for <Function test_use_root_instrument[True]>>
channel_instr = <DummyChannelInstrument: MonitorDummy>
use_root_instrument = True
@pytest.mark.parametrize("use_root_instrument", [True, False])
def test_use_root_instrument(request, channel_instr, use_root_instrument):
"""
Test instrument updates
"""
loop = asyncio.new_event_loop()
def cleanup_loop():
loop.stop()
loop.close()
request.addfinalizer(cleanup_loop)
asyncio.set_event_loop(loop)
> m = monitor.Monitor(
channel_instr.A.dummy_start,
channel_instr.B.dummy_start,
use_root_instrument=use_root_instrument,
)
qcodes\tests\test_monitor.py:1[83](https://github.com/QCoDeS/Qcodes/actions/runs/3217437938/jobs/5260403272#step:8:84):
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <Monitor(Thread-11, stopped 5308)>, interval = 1
use_root_instrument = True
parameters = (<qcodes.parameters.parameter.Parameter: dummy_start at 2660446689536>, <qcodes.parameters.parameter.Parameter: dummy_start at 2660446683296>)
parameter = <qcodes.parameters.parameter.Parameter: dummy_start at 2660446683296>
def __init__(
self,
*parameters: Parameter,
interval: float = 1,
use_root_instrument: bool = True,
):
"""
Monitor qcodes parameters.
Args:
*parameters: Parameters to monitor.
interval: How often one wants to refresh the values.
use_root_instrument: Defines if parameters are grouped according to
parameter.root_instrument or parameter.instrument
"""
super().__init__()
# Check that all values are valid parameters
for parameter in parameters:
if not isinstance(parameter, Parameter):
raise TypeError(f"We can only monitor QCodes "
f"Parameters, not {type(parameter)}")
self.loop: Optional[asyncio.AbstractEventLoop] = None
self.server: Optional["WebSocketServer"] = None
self._parameters = parameters
self.loop_is_closed = Event()
self.server_is_started = Event()
self.handler = _handler(
parameters, interval=interval, use_root_instrument=use_root_instrument
)
log.debug("Start monitoring thread")
if Monitor.running:
# stop the old server
log.debug("Stopping and restarting server")
Monitor.running.stop()
self.start()
# Wait until the loop is running
self.server_is_started.wait(timeout=5)
if not self.server_is_started.is_set():
> raise RuntimeError("Failed to start server")
E RuntimeError: Failed to start server
qcodes\monitor\monitor.py:189: RuntimeError
------------------------------ Captured log call ------------------------------
ERROR qcodes.monitor.monitor:monitor.py:208 Server could not be started
Traceback (most recent call last):
File "D:\a\Qcodes\Qcodes\qcodes\monitor\monitor.py", line 202, in run
self.server = self.loop.run_until_complete(server_start)
File "C:\hostedtoolcache\windows\Python\3.10.7\x64\lib\asyncio\base_events.py", line 646, in run_until_complete
return future.result()
File "C:\hostedtoolcache\windows\Python\3.10.7\x64\lib\asyncio\tasks.py", line 650, in _wrap_awaitable
return (yield from awaitable.__await__())
File "C:\hostedtoolcache\windows\Python\3.10.7\x64\lib\site-packages\websockets\legacy\server.py", line 1088, in __await_impl__
server = await self._create_server()
File "C:\hostedtoolcache\windows\Python\3.10.7\x64\lib\asyncio\base_events.py", line 1505, in create_server
raise OSError(err.errno, 'error while attempting '
PermissionError: [Errno 13] error while attempting to bind on address ('127.0.0.1', 57[85](https://github.com/QCoDeS/Qcodes/actions/runs/3217437938/jobs/5260403272#step:8:86)4): an attempt was made to access a socket in a way forbidden by its access permissions
_______________________ test_use_root_instrument[False] _______________________
[gw1] win32 -- Python 3.10.7 C:\hostedtoolcache\windows\Python\3.10.7\x64\python.exe
request = <FixtureRequest for <Function test_use_root_instrument[False]>>
channel_instr = <DummyChannelInstrument: MonitorDummy>
use_root_instrument = False
@pytest.mark.parametrize("use_root_instrument", [True, False])
def test_use_root_instrument(request, channel_instr, use_root_instrument):
"""
Test instrument updates
"""
loop = asyncio.new_event_loop()
def cleanup_loop():
loop.stop()
loop.close()
request.addfinalizer(cleanup_loop)
asyncio.set_event_loop(loop)
> m = monitor.Monitor(
channel_instr.A.dummy_start,
channel_instr.B.dummy_start,
use_root_instrument=use_root_instrument,
)
qcodes\tests\test_monitor.py:183:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <Monitor(Thread-12, stopped 1568)>, interval = 1
use_root_instrument = False
parameters = (<qcodes.parameters.parameter.Parameter: dummy_start at 2660449612608>, <qcodes.parameters.parameter.Parameter: dummy_start at 2660449600560>)
parameter = <qcodes.parameters.parameter.Parameter: dummy_start at 2660449600560>
def __init__(
self,
*parameters: Parameter,
interval: float = 1,
use_root_instrument: bool = True,
):
"""
Monitor qcodes parameters.
Args:
*parameters: Parameters to monitor.
interval: How often one wants to refresh the values.
use_root_instrument: Defines if parameters are grouped according to
parameter.root_instrument or parameter.instrument
"""
super().__init__()
# Check that all values are valid parameters
for parameter in parameters:
if not isinstance(parameter, Parameter):
raise TypeError(f"We can only monitor QCodes "
f"Parameters, not {type(parameter)}")
self.loop: Optional[asyncio.AbstractEventLoop] = None
self.server: Optional["WebSocketServer"] = None
self._parameters = parameters
self.loop_is_closed = Event()
self.server_is_started = Event()
self.handler = _handler(
parameters, interval=interval, use_root_instrument=use_root_instrument
)
log.debug("Start monitoring thread")
if Monitor.running:
# stop the old server
log.debug("Stopping and restarting server")
Monitor.running.stop()
self.start()
# Wait until the loop is running
self.server_is_started.wait(timeout=5)
if not self.server_is_started.is_set():
> raise RuntimeError("Failed to start server")
E RuntimeError: Failed to start server
qcodes\monitor\monitor.py:189: RuntimeError
------------------------------ Captured log call ------------------------------
ERROR qcodes.monitor.monitor:monitor.py:208 Server could not be started
Traceback (most recent call last):
File "D:\a\Qcodes\Qcodes\qcodes\monitor\monitor.py", line 202, in run
self.server = self.loop.run_until_complete(server_start)
File "C:\hostedtoolcache\windows\Python\3.10.7\x64\lib\asyncio\base_events.py", line 646, in run_until_complete
return future.result()
File "C:\hostedtoolcache\windows\Python\3.10.7\x64\lib\asyncio\tasks.py", line 650, in _wrap_awaitable
return (yield from awaitable.__await__())
File "C:\hostedtoolcache\windows\Python\3.10.7\x64\lib\site-packages\websockets\legacy\server.py", line 10[88](https://github.com/QCoDeS/Qcodes/actions/runs/3217437938/jobs/5260403272#step:8:89), in __await_impl__
server = await self._create_server()
File "C:\hostedtoolcache\windows\Python\3.10.7\x64\lib\asyncio\base_events.py", line 1505, in create_server
raise OSError(err.errno, 'error while attempting '
PermissionError: [Errno 13] error while attempting to bind on address ('[127](https://github.com/QCoDeS/Qcodes/actions/runs/3217437938/jobs/5260403272#step:8:128).0.0.1', [578](https://github.com/QCoDeS/Qcodes/actions/runs/3217437938/jobs/5260403272#step:8:579)54): an attempt was made to access a socket in a way forbidden by its access permissions
=================================== ERRORS ====================================
______________________ ERROR at setup of test_parameter _______________________
[gw1] win32 -- Python 3.10.7 C:\hostedtoolcache\windows\Python\3.10.7\x64\python.exe
@pytest.fixture(name="inst_and_monitor")
def _make_inst_and_monitor():
instr = DummyInstrument("MonitorDummy")
param = Parameter("DummyParam",
unit="V",
get_cmd=None,
set_cmd=None)
param(1)
monitor_parameters = tuple(instr.parameters.values())[1:]
> my_monitor = monitor.Monitor(*monitor_parameters, param, interval=0.1)
qcodes\tests\test_monitor.py:27:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <Monitor(Thread-10, stopped 4404)>, interval = 0.1
use_root_instrument = True
parameters = (<qcodes.parameters.parameter.Parameter: dac1 at 2660446451168>, <qcodes.parameters.parameter.Parameter: dac2 at 26604...ters.parameter.Parameter: dac3 at 2660446451264>, <qcodes.parameters.parameter.Parameter: DummyParam at 2660446442384>)
parameter = <qcodes.parameters.parameter.Parameter: DummyParam at 2660446442384>
def __init__(
self,
*parameters: Parameter,
interval: float = 1,
use_root_instrument: bool = True,
):
"""
Monitor qcodes parameters.
Args:
*parameters: Parameters to monitor.
interval: How often one wants to refresh the values.
use_root_instrument: Defines if parameters are grouped according to
parameter.root_instrument or parameter.instrument
"""
super().__init__()
# Check that all values are valid parameters
for parameter in parameters:
if not isinstance(parameter, Parameter):
raise TypeError(f"We can only monitor QCodes "
f"Parameters, not {type(parameter)}")
self.loop: Optional[asyncio.AbstractEventLoop] = None
self.server: Optional["WebSocketServer"] = None
self._parameters = parameters
self.loop_is_closed = Event()
self.server_is_started = Event()
self.handler = _handler(
parameters, interval=interval, use_root_instrument=use_root_instrument
)
log.debug("Start monitoring thread")
if Monitor.running:
# stop the old server
log.debug("Stopping and restarting server")
Monitor.running.stop()
self.start()
# Wait until the loop is running
self.server_is_started.wait(timeout=5)
if not self.server_is_started.is_set():
> raise RuntimeError("Failed to start server")
E RuntimeError: Failed to start server
qcodes\monitor\monitor.py:189: RuntimeError
----------------------------- Captured log setup ------------------------------
ERROR qcodes.monitor.monitor:monitor.py:208 Server could not be started
Traceback (most recent call last):
File "D:\a\Qcodes\Qcodes\qcodes\monitor\monitor.py", line 202, in run
self.server = self.loop.run_until_complete(server_start)
File "C:\hostedtoolcache\windows\Python\3.10.7\x64\lib\asyncio\base_events.py", line 646, in run_until_complete
return future.result()
File "C:\hostedtoolcache\windows\Python\3.10.7\x64\lib\asyncio\tasks.py", line 650, in _wrap_awaitable
return (yield from awaitable.__await__())
File "C:\hostedtoolcache\windows\Python\3.10.7\x64\lib\site-packages\websockets\legacy\server.py", line 1088, in __await_impl__
server = await self._create_server()
File "C:\hostedtoolcache\windows\Python\3.10.7\x64\lib\asyncio\base_events.py", line 1505, in create_server
raise OSError(err.errno, 'error while attempting '
PermissionError: [Errno 13] error while attempting to bind on address ('127.0.0.1', 5[78](https://github.com/QCoDeS/Qcodes/actions/runs/3217437938/jobs/5260403272#step:8:79)54): an attempt was made to access a socket in a way forbidden by its access permissions
================================== FAILURES ===================================
_____________________________ test_setup_teardown _____________________________
[gw1] win32 -- Python 3.10.7 C:\hostedtoolcache\windows\Python\3.10.7\x64\python.exe
request = <FixtureRequest for <Function test_setup_teardown>>
def test_setup_teardown(request):
"""
Check that monitor starts up and closes correctly
"""
> m = monitor.Monitor()
qcodes\tests\test_monitor.py:49:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <Monitor(Thread-6, stopped 6960)>, interval = 1
use_root_instrument = True, parameters = ()
def __init__(
self,
*parameters: Parameter,
interval: float = 1,
use_root_instrument: bool = True,
):
"""
Monitor qcodes parameters.
Args:
*parameters: Parameters to monitor.
interval: How often one wants to refresh the values.
use_root_instrument: Defines if parameters are grouped according to
parameter.root_instrument or parameter.instrument
"""
super().__init__()
# Check that all values are valid parameters
for parameter in parameters:
if not isinstance(parameter, Parameter):
raise TypeError(f"We can only monitor QCodes "
f"Parameters, not {type(parameter)}")
self.loop: Optional[asyncio.AbstractEventLoop] = None
self.server: Optional["WebSocketServer"] = None
self._parameters = parameters
self.loop_is_closed = Event()
self.server_is_started = Event()
self.handler = _handler(
parameters, interval=interval, use_root_instrument=use_root_instrument
)
log.debug("Start monitoring thread")
if Monitor.running:
# stop the old server
log.debug("Stopping and restarting server")
Monitor.running.stop()
self.start()
# Wait until the loop is running
self.server_is_started.wait(timeout=5)
if not self.server_is_started.is_set():
> raise RuntimeError("Failed to start server")
E RuntimeError: Failed to start server
qcodes\monitor\monitor.py:189: RuntimeError
------------------------------ Captured log call ------------------------------
ERROR qcodes.monitor.monitor:monitor.py:208 Server could not be started
Traceback (most recent call last):
File "D:\a\Qcodes\Qcodes\qcodes\monitor\monitor.py", line 202, in run
self.server = self.loop.run_until_complete(server_start)
File "C:\hostedtoolcache\windows\Python\3.10.7\x64\lib\asyncio\base_events.py", line 646, in run_until_complete
return future.result()
File "C:\hostedtoolcache\windows\Python\3.10.7\x64\lib\asyncio\tasks.py", line 650, in _wrap_awaitable
return (yield from awaitable.__await__())
File "C:\hostedtoolcache\windows\Python\3.10.7\x64\lib\site-packages\websockets\legacy\server.py", line 1088, in __await_impl__
server = await self._create_server()
File "C:\hostedtoolcache\windows\Python\3.10.7\x64\lib\asyncio\base_events.py", line 1505, in create_server
raise OSError(err.errno, 'error while attempting '
PermissionError: [Errno 13] error while attempting to bind on address ('127.0.0.1', 57854): an attempt was made to access a socket in a way forbidden by its access permissions
____________________________ test_monitor_replace _____________________________
[gw1] win32 -- Python 3.10.7 C:\hostedtoolcache\windows\Python\3.10.7\x64\python.exe
request = <FixtureRequest for <Function test_monitor_replace>>
def test_monitor_replace(request):
"""
Check that monitors get correctly replaced
"""
> m = monitor.Monitor()
qcodes\tests\test_monitor.py:65:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <Monitor(Thread-7, stopped 6268)>, interval = 1
use_root_instrument = True, parameters = ()
def __init__(
self,
*parameters: Parameter,
interval: float = 1,
use_root_instrument: bool = True,
):
"""
Monitor qcodes parameters.
Args:
*parameters: Parameters to monitor.
interval: How often one wants to refresh the values.
use_root_instrument: Defines if parameters are grouped according to
parameter.root_instrument or parameter.instrument
"""
super().__init__()
# Check that all values are valid parameters
for parameter in parameters:
if not isinstance(parameter, Parameter):
raise TypeError(f"We can only monitor QCodes "
f"Parameters, not {type(parameter)}")
self.loop: Optional[asyncio.AbstractEventLoop] = None
self.server: Optional["WebSocketServer"] = None
self._parameters = parameters
self.loop_is_closed = Event()
self.server_is_started = Event()
self.handler = _handler(
parameters, interval=interval, use_root_instrument=use_root_instrument
)
log.debug("Start monitoring thread")
if Monitor.running:
# stop the old server
log.debug("Stopping and restarting server")
Monitor.running.stop()
self.start()
# Wait until the loop is running
self.server_is_started.wait(timeout=5)
if not self.server_is_started.is_set():
> raise RuntimeError("Failed to start server")
E RuntimeError: Failed to start server
qcodes\monitor\monitor.py:189: RuntimeError
------------------------------ Captured log call ------------------------------
ERROR qcodes.monitor.monitor:monitor.py:208 Server could not be started
Traceback (most recent call last):
File "D:\a\Qcodes\Qcodes\qcodes\monitor\monitor.py", line 202, in run
self.server = self.loop.run_until_complete(server_start)
File "C:\hostedtoolcache\windows\Python\3.10.7\x64\lib\asyncio\base_events.py", line 646, in run_until_complete
return future.result()
File "C:\hostedtoolcache\windows\Python\3.10.7\x64\lib\asyncio\tasks.py", line 650, in _wrap_awaitable
return (yield from awaitable.__await__())
File "C:\hostedtoolcache\windows\Python\3.10.7\x64\lib\site-packages\websockets\legacy\server.py", line 1088, in __await_impl__
server = await self._create_server()
File "C:\hostedtoolcache\windows\Python\3.10.7\x64\lib\asyncio\base_events.py", line 1505, in create_server
raise OSError(err.errno, 'error while attempting '
PermissionError: [Errno 13] error while attempting to bind on address ('127.0.0.1', 57854): an attempt was made to access a socket in a way forbidden by its access permissions
______________________________ test_double_join _______________________________
[gw1] win32 -- Python 3.10.7 C:\hostedtoolcache\windows\Python\3.10.7\x64\python.exe
request = <FixtureRequest for <Function test_double_join>>
def test_double_join(request):
"""
Check that a double join doesn't cause a hang
"""
> m = monitor.Monitor()
qcodes\tests\test_monitor.py:[81](https://github.com/QCoDeS/Qcodes/actions/runs/3217437938/jobs/5260403272#step:8:82):
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <Monitor(Thread-8, stopped 5024)>, interval = 1
use_root_instrument = True, parameters = ()
def __init__(
self,
*parameters: Parameter,
interval: float = 1,
use_root_instrument: bool = True,
):
"""
Monitor qcodes parameters.
Args:
*parameters: Parameters to monitor.
interval: How often one wants to refresh the values.
use_root_instrument: Defines if parameters are grouped according to
parameter.root_instrument or parameter.instrument
"""
super().__init__()
# Check that all values are valid parameters
for parameter in parameters:
if not isinstance(parameter, Parameter):
raise TypeError(f"We can only monitor QCodes "
f"Parameters, not {type(parameter)}")
self.loop: Optional[asyncio.AbstractEventLoop] = None
self.server: Optional["WebSocketServer"] = None
self._parameters = parameters
self.loop_is_closed = Event()
self.server_is_started = Event()
self.handler = _handler(
parameters, interval=interval, use_root_instrument=use_root_instrument
)
log.debug("Start monitoring thread")
if Monitor.running:
# stop the old server
log.debug("Stopping and restarting server")
Monitor.running.stop()
self.start()
# Wait until the loop is running
self.server_is_started.wait(timeout=5)
if not self.server_is_started.is_set():
> raise RuntimeError("Failed to start server")
E RuntimeError: Failed to start server
qcodes\monitor\monitor.py:189: RuntimeError
------------------------------ Captured log call ------------------------------
ERROR qcodes.monitor.monitor:monitor.py:208 Server could not be started
Traceback (most recent call last):
File "D:\a\Qcodes\Qcodes\qcodes\monitor\monitor.py", line 202, in run
self.server = self.loop.run_until_complete(server_start)
File "C:\hostedtoolcache\windows\Python\3.10.7\x64\lib\asyncio\base_events.py", line 646, in run_until_complete
return future.result()
File "C:\hostedtoolcache\windows\Python\3.10.7\x64\lib\asyncio\tasks.py", line 650, in _wrap_awaitable
return (yield from awaitable.__await__())
File "C:\hostedtoolcache\windows\Python\3.10.7\x64\lib\site-packages\websockets\legacy\server.py", line 1088, in __await_impl__
server = await self._create_server()
File "C:\hostedtoolcache\windows\Python\3.10.7\x64\lib\asyncio\base_events.py", line 1505, in create_server
raise OSError(err.errno, 'error while attempting '
PermissionError: [Errno 13] error while attempting to bind on address ('127.0.0.1', 57854): an attempt was made to access a socket in a way forbidden by its access permissions
_______________________________ test_connection _______________________________
[gw1] win32 -- Python 3.10.7 C:\hostedtoolcache\windows\Python\3.10.7\x64\python.exe
request = <FixtureRequest for <Function test_connection>>
def test_connection(request):
"""
Test that we can connect to a monitor instance
"""
> m = monitor.Monitor()
qcodes\tests\test_monitor.py:92:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <Monitor(Thread-9, stopped 1492)>, interval = 1
use_root_instrument = True, parameters = ()
def __init__(
self,
*parameters: Parameter,
interval: float = 1,
use_root_instrument: bool = True,
):
"""
Monitor qcodes parameters.
Args:
*parameters: Parameters to monitor.
interval: How often one wants to refresh the values.
use_root_instrument: Defines if parameters are grouped according to
parameter.root_instrument or parameter.instrument
"""
super().__init__()
# Check that all values are valid parameters
for parameter in parameters:
if not isinstance(parameter, Parameter):
raise TypeError(f"We can only monitor QCodes "
f"Parameters, not {type(parameter)}")
self.loop: Optional[asyncio.AbstractEventLoop] = None
self.server: Optional["WebSocketServer"] = None
self._parameters = parameters
self.loop_is_closed = Event()
NoTagError: `git describe` could not find a tag
self.server_is_started = Event()
self.handler = _handler(
parameters, interval=interval, use_root_instrument=use_root_instrument
)
log.debug("Start monitoring thread")
if Monitor.running:
# stop the old server
log.debug("Stopping and restarting server")
Monitor.running.stop()
self.start()
# Wait until the loop is running
self.server_is_started.wait(timeout=5)
if not self.server_is_started.is_set():
> raise RuntimeError("Failed to start server")
E RuntimeError: Failed to start server
qcodes\monitor\monitor.py:189: RuntimeError
------------------------------ Captured log call ------------------------------
ERROR qcodes.monitor.monitor:monitor.py:208 Server could not be started
Traceback (most recent call last):
File "D:\a\Qcodes\Qcodes\qcodes\monitor\monitor.py", line 202, in run
self.server = self.loop.run_until_complete(server_start)
File "C:\hostedtoolcache\windows\Python\3.10.7\x64\lib\asyncio\base_events.py", line 646, in run_until_complete
return future.result()
File "C:\hostedtoolcache\windows\Python\3.10.7\x64\lib\asyncio\tasks.py", line 650, in _wrap_awaitable
return (yield from awaitable.__await__())
File "C:\hostedtoolcache\windows\Python\3.10.7\x64\lib\site-packages\websockets\legacy\server.py", line 1088, in __await_impl__
server = await self._create_server()
File "C:\hostedtoolcache\windows\Python\3.10.7\x64\lib\asyncio\base_events.py", line 1505, in create_server
raise OSError(err.errno, 'error while attempting '
PermissionError: [Errno 13] error while attempting to bind on address ('127.0.0.1', 57854): an attempt was made to access a socket in a way forbidden by its access permissions
_______________________ test_use_root_instrument[True] ________________________
[gw1] win32 -- Python 3.10.7 C:\hostedtoolcache\windows\Python\3.10.7\x64\python.exe
request = <FixtureRequest for <Function test_use_root_instrument[True]>>
channel_instr = <DummyChannelInstrument: MonitorDummy>
use_root_instrument = True
@pytest.mark.parametrize("use_root_instrument", [True, False])
def test_use_root_instrument(request, channel_instr, use_root_instrument):
"""
Test instrument updates
"""
loop = asyncio.new_event_loop()
def cleanup_loop():
loop.stop()
loop.close()
request.addfinalizer(cleanup_loop)
asyncio.set_event_loop(loop)
> m = monitor.Monitor(
channel_instr.A.dummy_start,
channel_instr.B.dummy_start,
use_root_instrument=use_root_instrument,
)
qcodes\tests\test_monitor.py:1[83](https://github.com/QCoDeS/Qcodes/actions/runs/3217437938/jobs/5260403272#step:8:84):
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <Monitor(Thread-11, stopped 5308)>, interval = 1
use_root_instrument = True
parameters = (<qcodes.parameters.parameter.Parameter: dummy_start at 2660446689536>, <qcodes.parameters.parameter.Parameter: dummy_start at 2660446683296>)
parameter = <qcodes.parameters.parameter.Parameter: dummy_start at 2660446683296>
def __init__(
self,
*parameters: Parameter,
interval: float = 1,
use_root_instrument: bool = True,
):
"""
Monitor qcodes parameters.
Args:
*parameters: Parameters to monitor.
interval: How often one wants to refresh the values.
use_root_instrument: Defines if parameters are grouped according to
parameter.root_instrument or parameter.instrument
"""
super().__init__()
# Check that all values are valid parameters
for parameter in parameters:
if not isinstance(parameter, Parameter):
raise TypeError(f"We can only monitor QCodes "
f"Parameters, not {type(parameter)}")
self.loop: Optional[asyncio.AbstractEventLoop] = None
self.server: Optional["WebSocketServer"] = None
self._parameters = parameters
self.loop_is_closed = Event()
self.server_is_started = Event()
self.handler = _handler(
parameters, interval=interval, use_root_instrument=use_root_instrument
)
log.debug("Start monitoring thread")
if Monitor.running:
# stop the old server
log.debug("Stopping and restarting server")
Monitor.running.stop()
self.start()
# Wait until the loop is running
self.server_is_started.wait(timeout=5)
if not self.server_is_started.is_set():
> raise RuntimeError("Failed to start server")
E RuntimeError: Failed to start server
qcodes\monitor\monitor.py:189: RuntimeError
------------------------------ Captured log call ------------------------------
ERROR qcodes.monitor.monitor:monitor.py:208 Server could not be started
Traceback (most recent call last):
File "D:\a\Qcodes\Qcodes\qcodes\monitor\monitor.py", line 202, in run
self.server = self.loop.run_until_complete(server_start)
File "C:\hostedtoolcache\windows\Python\3.10.7\x64\lib\asyncio\base_events.py", line 646, in run_until_complete
return future.result()
File "C:\hostedtoolcache\windows\Python\3.10.7\x64\lib\asyncio\tasks.py", line 650, in _wrap_awaitable
return (yield from awaitable.__await__())
File "C:\hostedtoolcache\windows\Python\3.10.7\x64\lib\site-packages\websockets\legacy\server.py", line 1088, in __await_impl__
server = await self._create_server()
File "C:\hostedtoolcache\windows\Python\3.10.7\x64\lib\asyncio\base_events.py", line 1505, in create_server
raise OSError(err.errno, 'error while attempting '
PermissionError: [Errno 13] error while attempting to bind on address ('127.0.0.1', 57[85](https://github.com/QCoDeS/Qcodes/actions/runs/3217437938/jobs/5260403272#step:8:86)4): an attempt was made to access a socket in a way forbidden by its access permissions
_______________________ test_use_root_instrument[False] _______________________
[gw1] win32 -- Python 3.10.7 C:\hostedtoolcache\windows\Python\3.10.7\x64\python.exe
request = <FixtureRequest for <Function test_use_root_instrument[False]>>
channel_instr = <DummyChannelInstrument: MonitorDummy>
use_root_instrument = False
@pytest.mark.parametrize("use_root_instrument", [True, False])
def test_use_root_instrument(request, channel_instr, use_root_instrument):
"""
Test instrument updates
"""
loop = asyncio.new_event_loop()
def cleanup_loop():
loop.stop()
loop.close()
request.addfinalizer(cleanup_loop)
asyncio.set_event_loop(loop)
> m = monitor.Monitor(
channel_instr.A.dummy_start,
channel_instr.B.dummy_start,
use_root_instrument=use_root_instrument,
)
qcodes\tests\test_monitor.py:183:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <Monitor(Thread-12, stopped 1568)>, interval = 1
use_root_instrument = False
parameters = (<qcodes.parameters.parameter.Parameter: dummy_start at 2660449612608>, <qcodes.parameters.parameter.Parameter: dummy_start at 2660449600560>)
parameter = <qcodes.parameters.parameter.Parameter: dummy_start at 2660449600560>
def __init__(
self,
*parameters: Parameter,
interval: float = 1,
use_root_instrument: bool = True,
):
"""
Monitor qcodes parameters.
Args:
*parameters: Parameters to monitor.
interval: How often one wants to refresh the values.
use_root_instrument: Defines if parameters are grouped according to
parameter.root_instrument or parameter.instrument
"""
super().__init__()
# Check that all values are valid parameters
for parameter in parameters:
if not isinstance(parameter, Parameter):
raise TypeError(f"We can only monitor QCodes "
f"Parameters, not {type(parameter)}")
self.loop: Optional[asyncio.AbstractEventLoop] = None
self.server: Optional["WebSocketServer"] = None
self._parameters = parameters
self.loop_is_closed = Event()
self.server_is_started = Event()
self.handler = _handler(
parameters, interval=interval, use_root_instrument=use_root_instrument
)
log.debug("Start monitoring thread")
if Monitor.running:
# stop the old server
log.debug("Stopping and restarting server")
Monitor.running.stop()
self.start()
# Wait until the loop is running
self.server_is_started.wait(timeout=5)
if not self.server_is_started.is_set():
> raise RuntimeError("Failed to start server")
E RuntimeError: Failed to start server
qcodes\monitor\monitor.py:189: RuntimeError
------------------------------ Captured log call ------------------------------
ERROR qcodes.monitor.monitor:monitor.py:208 Server could not be started
Traceback (most recent call last):
File "D:\a\Qcodes\Qcodes\qcodes\monitor\monitor.py", line 202, in run
self.server = self.loop.run_until_complete(server_start)
File "C:\hostedtoolcache\windows\Python\3.10.7\x64\lib\asyncio\base_events.py", line 646, in run_until_complete
return future.result()
File "C:\hostedtoolcache\windows\Python\3.10.7\x64\lib\asyncio\tasks.py", line 650, in _wrap_awaitable
return (yield from awaitable.__await__())
File "C:\hostedtoolcache\windows\Python\3.10.7\x64\lib\site-packages\websockets\legacy\server.py", line 10[88](https://github.com/QCoDeS/Qcodes/actions/runs/3217437938/jobs/5260403272#step:8:89), in __await_impl__
server = await self._create_server()
File "C:\hostedtoolcache\windows\Python\3.10.7\x64\lib\asyncio\base_events.py", line 1505, in create_server
raise OSError(err.errno, 'error while attempting '
PermissionError: [Errno 13] error while attempting to bind on address ('[127](https://github.com/QCoDeS/Qcodes/actions/runs/3217437938/jobs/5260403272#step:8:128).0.0.1', [578](https://github.com/QCoDeS/Qcodes/actions/runs/3217437938/jobs/5260403272#step:8:579)54): an attempt was made to access a socket in a way forbidden by its access permissions