Client restart fails
Using picotech-adc-triggered
daemon.
>>> c = yaqc.Client([port])
>>> c.shutdown(restart=True)
Daemon feedback:
<6> INFO : 2020-12-31T14:24:22-0600 : scope : Shutting Down scope
<6> INFO : 2020-12-31T14:24:22-0600 : scope : Cancelling 2 outstanding tasks
<6> INFO : 2020-12-31T14:24:22-0600 : scope : Config File Path = ~\AppData\Local\yaq\yaqd\picotech-adc-triggered\config.toml
<6> INFO : 2020-12-31T14:24:22-0600 : scope : State File Path = ~\AppData\Local\yaq\yaqd-state\picotech-adc-triggered\scope-state.toml
<6> INFO : 2020-12-31T14:24:22-0600 : scope : TCP Port = 39003
Task exception was never retrieved
future: <Task finished coro=<IsDaemon._start_daemon() done, defined at ~\Documents\source\yaq-python\yaqd-core\yaqd_core\_is_daemon.py:220> exception=UnboundLocalError("local variable 'daemon' referenced before assignment")>
Traceback (most recent call last):
File "~\Documents\source\yaq-python\yaqd-core\yaqd_core\_is_daemon.py", line 240, in
_start_daemon
server(daemon), config.get("host", ""), config.get("port", None)
UnboundLocalError: local variable 'daemon' referenced before assignment
<6> INFO : 2020-12-31T14:24:26-0600 : scope : Connection lost from ('127.0.0.1', 57937) to scope
Task exception was never retrieved
future: <Task finished coro=<HasMeasureTrigger._runner() done, defined at ~\Documents\source\yaq-python\yaqd-core\yaqd_core\_has_measure_trigger.py:53> exception=AttributeError("'PicotechAdcTriggered' object has no attribute 'chandle'")>
Traceback (most recent call last):
File "~\Documents\source\yaq-python\yaqd-core\yaqd_core\_has_measure_trigger.py", line 56, in _runner
self._measured = await self._measure()
File "~\Documents\source\yaqd-picotech\yaqd_picotech\_picotech_adc_triggered.py", line 227, in _measure
samples = await self._loop.run_in_executor(None, self._measure_samples)
File "~\Anaconda3\lib\concurrent\futures\thread.py", line 57, in run
result = self.fn(*self.args, **self.kwargs)
File "~\Documents\source\yaqd-picotech\yaqd_picotech\_picotech_adc_triggered.py", line 273, in _measure_samples
self._create_task()
File "~\Documents\source\yaqd-picotech\yaqd_picotech\_picotech_adc_triggered.py", line 215, in _create_task
self.chandle,
AttributeError: 'PicotechAdcTriggered' object has no attribute 'chandle'
exception calling callback for <Future at 0x1ec83a45148 state=finished returned dict>
Traceback (most recent call last):
File "~\Anaconda3\lib\concurrent\futures\_base.py", line 324, in _invoke_callbacks
callback(self)
File "~\Anaconda3\lib\asyncio\futures.py", line 362, in _call_set_state
dest_loop.call_soon_threadsafe(_set_state, destination, source)
File "~\Anaconda3\lib\asyncio\base_events.py", line 728, in call_soon_threadsafe
self._check_closed()
File "~\Anaconda3\lib\asyncio\base_events.py", line 475, in _check_closed
raise RuntimeError('Event loop is closed')
RuntimeError: Event loop is closed
Task was destroyed but it is pending!
task: <Task pending coro=<HasMeasureTrigger._runner() running at ~\Documents\source\yaq-python\yaqd-core\yaqd_core\_has_measure_trigger.py:56> wait_for=<Future pending cb=[_chain_future.<locals>._call_check_cancel() at ~\Anaconda3\lib\asyncio\futures.py:348, <TaskWakeupMethWrapper object at 0x000001EC839DD858>()]>>
Task was destroyed but it is pending!
task: <Task pending coro=<IsDaemon.save_state() done, defined at ~\Documents\source\yaq-python\yaqd-core\yaqd_core\_is_daemon.py:327> wait_for=<Future pending cb=[<TaskWakeupMethWrapper object at 0x000001EC839A7E28>()]>>
The first error within _start_daemon
, UnboundLocalError: local variable 'daemon' referenced before assignment
, can be traced to this block of code:
try:
daemon = cls(name, config, config_filepath)
except Exception as e:
# TODO: logging
if not cls._daemons:
sys.exit(e)
else:
cls._daemons.append(daemon)
The restart triggers a "Unsuccessful API call" exception, and the _daemons list is not empty, so it escapes without defining daemon
.
A potential key element to this is daemon is that opening the device takes a few seconds, so __init__
might be slower than other HasMeasureTrigger
daemons we have used and create new race conditions.
Edited by Dan Kohler