light-scattering-io / caqtus

Package that provides tools to control an experiment
MIT License
0 stars 0 forks source link

Exception when closing condetrol main window #18

Closed light-scattering-io closed 3 months ago

light-scattering-io commented 3 months ago

Describe the bug

When closing the condetrol window with the close button, the following traceback will be displayed.

Expected behavior

Closing the application normally should not display an error. Especially, it might hide more important issues.

To Reproduce Steps to reproduce the behavior:

  1. Launch the Condetrol app
  2. Click on the close button
  3. The following error is displayed in the console

    Traceback (most recent call last):
      File "C:\Users\James\AppData\Local\Programs\Python\Python311\Lib\asyncio\runners.py", line 190, in run
        return runner.run(main)
               ^^^^^^^^^^^^^^^^
      File "C:\Users\James\AppData\Local\Programs\Python\Python311\Lib\asyncio\runners.py", line 118, in run
        return self._loop.run_until_complete(task)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "C:\Users\James\Desktop\caqtus_v2\Dy\.venv\Lib\site-packages\caqtus\gui\qtutil\QtAsyncio\events.py", line 194, in run_until_complete
        raise RuntimeError("Event loop stopped before Future completed")
    RuntimeError: Event loop stopped before Future completed
    
    During handling of the above exception, another exception occurred:
    
    Traceback (most recent call last):
      File "C:\Users\James\Desktop\caqtus_v2\Dy\launch_condetrol.py", line 35, in <module>
        dy_experiment.launch_condetrol()
      File "C:\Users\James\Desktop\caqtus_v2\Dy\.venv\Lib\site-packages\caqtus\extension\_experiment.py", line 214, in launch_condetrol
        app.run()
      File "C:\Users\James\Desktop\caqtus_v2\Dy\.venv\Lib\site-packages\caqtus\gui\condetrol\condetrol.py", line 95, in run
        QtAsyncio.run(self.window.run_async(), keep_running=False)
      File "C:\Users\James\Desktop\caqtus_v2\Dy\.venv\Lib\site-packages\caqtus\gui\qtutil\QtAsyncio\__init__.py", line 49, in run
        ret = asyncio.run(coro, debug=debug)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "C:\Users\James\AppData\Local\Programs\Python\Python311\Lib\asyncio\runners.py", line 189, in run
        with Runner(debug=debug) as runner:
      File "C:\Users\James\AppData\Local\Programs\Python\Python311\Lib\asyncio\runners.py", line 63, in __exit__
        self.close()
      File "C:\Users\James\AppData\Local\Programs\Python\Python311\Lib\asyncio\runners.py", line 71, in close
        _cancel_all_tasks(loop)
      File "C:\Users\James\AppData\Local\Programs\Python\Python311\Lib\asyncio\runners.py", line 201, in _cancel_all_tasks
        loop.run_until_complete(tasks.gather(*to_cancel, return_exceptions=True))
      File "C:\Users\James\Desktop\caqtus_v2\Dy\.venv\Lib\site-packages\caqtus\gui\qtutil\QtAsyncio\events.py", line 176, in run_until_complete
        raise RuntimeError("Event loop is closed")
    RuntimeError: Event loop is closed
    Exception ignored in: <coroutine object SequenceWidget.exec_async at 0x000002025D81ECF0>
    Traceback (most recent call last):
      File "C:\Users\James\Desktop\caqtus_v2\Dy\.venv\Lib\site-packages\caqtus\gui\condetrol\sequence_widget\sequence_widget.py", line 138, in exec_async
      File "C:\Users\James\Desktop\caqtus_v2\Dy\.venv\Lib\site-packages\caqtus\gui\condetrol\sequence_widget\sequence_widget.py", line 146, in watch_sequence
      File "C:\Users\James\Desktop\caqtus_v2\Dy\.venv\Lib\site-packages\caqtus\gui\condetrol\sequence_widget\sequence_widget.py", line 281, in _query_state_async
      File "C:\Users\James\Desktop\caqtus_v2\Dy\.venv\Lib\site-packages\caqtus\session\sql\_async_session.py", line 119, in __aexit__
      File "C:\Users\James\AppData\Local\Programs\Python\Python311\Lib\asyncio\threads.py", line 22, in to_thread
    RuntimeError: no running event loop
damienBloch commented 3 months ago

I think this might be an issue with QtAsyncio itself, see this issue.