Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

H5 worker thread cannot be terminated at will #60

Open
leofang opened this issue Aug 5, 2019 · 4 comments
Open

H5 worker thread cannot be terminated at will #60

leofang opened this issue Aug 5, 2019 · 4 comments

Comments

@leofang
Copy link
Collaborator

leofang commented Aug 5, 2019

This is a follow-up of #26. The following code snippet was commented out because it would freeze the whole window:

#if self.roiWindow._worker_thread.isRunning():
# self.roiWindow._worker_thread.terminate()
# self.roiWindow._worker_thread.wait()

The offending call is thread.terminate(). As a result, currently during batch processing if one clicks "Stop", the H5 worker will still finish up the work in the background. Only the whole processing queue is killed.

If a more recent Qt/PyQt5 is available (at least 5.10) we should revisit this problem. I suspect it's the underlying implementation causing the problem.

@leofang
Copy link
Collaborator Author

leofang commented Aug 5, 2019

Need to ask Anaconda folks to update Qt/PyQt: ContinuumIO/anaconda-issues#9124

@leofang
Copy link
Collaborator Author

leofang commented Aug 12, 2019

If a more recent Qt/PyQt5 is available (at least 5.10) we should revisit this problem. I suspect it's the underlying implementation causing the problem.

It's probably not this reason. Tried building PyQt 5.12.3 (conda-forge/pyqt-feedstock#61) on top of condo-forge's new Qt 5.12.1 (conda-forge/qt-feedstock#110). Still hangs. I probably used thread.terminate() wrong, but I still can't figure out why...

@tacaswell
Copy link
Member

What is the type of HardWorker?

@leofang
Copy link
Collaborator Author

leofang commented Aug 12, 2019

It inherits from QThread and its run method is overridden:

# a worker that does the rest of hard work for us
class HardWorker(QtCore.QThread):
update_signal = QtCore.pyqtSignal(int, object) # connect to MainWindow???
def __init__(self, task=None, *args, parent=None):
super().__init__(parent)
self.task = task
self.args = args
self.exception_handler = None
#self.update_signal = QtCore.pyqtSignal(int, object) # connect to MainWindow???
def run(self):
try:
if self.task == "save_h5":
self._save_h5(self.update_signal.emit)
elif self.task == "fetch_data":
self._fetch_data(self.update_signal.emit)
# TODO: put other heavy lifting works here
# TODO: consider merge other worker threads to this one?
except ValueError as ex:
# from _fetch_data(), print it and quit
print(ex, file=sys.stderr)
print("[ERROR] possible reason: no image available for the selected detector/scan", file=sys.stderr)
except Exception as ex:
# use MainWindow's exception handler
if self.exception_handler is not None:
self.exception_handler(ex)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants