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

Stop button should kill calibration and deconvolution processes #37

Open
gschlafly opened this issue Jan 30, 2023 · 2 comments
Open

Stop button should kill calibration and deconvolution processes #37

gschlafly opened this issue Jan 30, 2023 · 2 comments
Labels
bug Something isn't working

Comments

@gschlafly
Copy link
Member

Description

Currently, when the Stop button is pushed, the calibration and deconvolution computation processes continue to run on the CPU/GPU. This is evident by the output in the terminal window.

Files

@self.gui.btn_stop.changed.connect
def btn_stop_call():
self.thread_worker.quit()
self.gui.set_btns_and_status(True, LFvals.PLUGIN_ARGS['main']['status']['value_idle'])

Solution ideas

Try to fix once https://github.com/PolarizedLightFieldMicroscopy/LFAnalyze-fundamentals/issues/7 is fixed. The line self.thread_worker.quit() should stop the computations.

@gschlafly gschlafly added the bug Something isn't working label Jan 30, 2023
@amitabhverma
Copy link
Contributor

Adding a quote for reference : https://napari.org/stable/api/napari.qt.threading.FunctionWorker.html

!!! important

If the user does not put any yields in their function, and the function is super long, it will just hang… For instance, there’s no graceful way to kill this thread in python:

This is why it’s always advisable to use a generator that periodically yields for long-running computations in another thread.

See this stack-overflow post for a good discussion on the difficulty of killing a rogue python thread:

@amitabhverma
Copy link
Contributor

Another useful reference : https://forum.image.sc/t/how-to-terminate-a-worker-in-thread-worker-in-napari/53822/2

Talley Lambert:
yep! That’s correct. You don’t even need to actually “yield” something either. just need to sprinkle them in there. This is >obviously easiest if your long-running function already iterates somehow. But, it can be tricky in certain cases.

@thread_worker
def long_runner():
    for _ range(whetever):
        ...
        yield

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants