KBNLresearch / iromlab

Loader software for automated imaging of optical media with Nimbie disc robot
Apache License 2.0
31 stars 5 forks source link

RuntimeError: main thread is not in main loop after pressing Exit #37

Closed bitsgalore closed 7 years ago

bitsgalore commented 7 years ago

What I did:

Result:

Exception in thread Thread-3:
Traceback (most recent call last):
  File "c:\python36\lib\threading.py", line 916, in _bootstrap_inner
    self.run()
  File "c:\python36\lib\threading.py", line 864, in run
    self._target(*self._args, **self._kwargs)
  File "f:\johan\pythonCode\iromlab\iromlab\cdworker.py", line 484, in cdWorker
    logging.info('*** Quitting because user pressed Exit ***')
  File "c:\python36\lib\logging\__init__.py", line 1870, in info
    root.info(msg, *args, **kwargs)
  File "c:\python36\lib\logging\__init__.py", line 1301, in info
    self._log(INFO, msg, args, **kwargs)
  File "c:\python36\lib\logging\__init__.py", line 1437, in _log
    self.handle(record)
  File "c:\python36\lib\logging\__init__.py", line 1447, in handle
    self.callHandlers(record)
  File "c:\python36\lib\logging\__init__.py", line 1509, in callHandlers
    hdlr.handle(record)
  File "c:\python36\lib\logging\__init__.py", line 858, in handle
    self.emit(record)
  File "f:\johan\pythonCode\iromlab\iromlab\iromlab.py", line 356, in emit
    self.text.after(0, append)
  File "c:\python36\lib\tkinter\__init__.py", line 752, in after
    name = self._register(callit)
  File "c:\python36\lib\tkinter\__init__.py", line 1366, in _register
    self.tk.createcommand(name, f)
RuntimeError: main thread is not in main loop

By going through the steps above this happens sometimes, but not always! Error appears to be triggered by this line (which tries to write something using the logging module):

https://github.com/KBNLresearch/iromlab/blob/master/iromlab/cdworker.py#L488

Could be some weird/rare race condition.

ADDITION: error can also occur if no disc was processed at all.

bitsgalore commented 7 years ago

Looks like same/similar issue as: https://github.com/KBNLresearch/iromlab/issues/50

bitsgalore commented 7 years ago

Added 2-second delay before quitting: https://github.com/KBNLresearch/iromlab/commit/5f9a32a02685b086b350514b928f30aec144e933

bitsgalore commented 7 years ago

Issue not (completely) fixed; error still occurs under following condition:

  1. Fire up iromlab
  2. Create new batch
  3. Press exit before initialization of batch has completed

In some cases no error is displayed but Iromlab just freezes.

bitsgalore commented 7 years ago

Behaviour when on_quit is activated has been given an overhaul in https://github.com/KBNLresearch/iromlab/commit/ed1cb3540fd883ea0c262b310fc174afc13b4ab5; hopefully this will resolve these issues.