Skip to content

Handle OS termination signals.#425

Merged
2 commits merged into
arsenetar:masterfrom
jlesage:master-handle-os-signals
Jun 20, 2017
Merged

Handle OS termination signals.#425
2 commits merged into
arsenetar:masterfrom
jlesage:master-handle-os-signals

Conversation

@jlesage

@jlesage jlesage commented Jun 19, 2017

Copy link
Copy Markdown
Contributor

This pull request allows dupeGuru to terminate gracefully when receiving an OS signal.

Comment thread run.py
setUpSignals()
# Let the Python interpreter run every 500ms to handle signals.
from PyQt5.QtCore import QTimer
timer = QTimer()

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand this. What happens if we don't have this timer? Qt's runloop doesn't let signal handling work properly?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exactly. Without this, Python cannot handle signals while the Qt event loop is running.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we please have a comment that mentions the Qt's runloop then? The role of this piece of code is hard to grasp without the context of the PR.

@ghost

ghost commented Jun 19, 2017

Copy link
Copy Markdown

Thanks for this PR. Although I'm not sure I understand the actual use case, it's usually a good idea to gracefully handle those things. I'll give it a try soon.

@ghost ghost self-assigned this Jun 19, 2017
@jlesage

jlesage commented Jun 19, 2017

Copy link
Copy Markdown
Contributor Author

Here is some context about the reason I did this fix:

dupeGuru saves some stuff only during its shutdown routine. If the application is terminated via signals, the shutdown routine is not called and thus not everything is saved to disk.

I created a docker container to run dupeGuru. With this fix, we can stop and restart the container and make dupeGuru shutdown gracefully. In other words, dupeGuru properly saves everything when the container is restarted/stopped.

@jlesage

jlesage commented Jun 19, 2017

Copy link
Copy Markdown
Contributor Author

@ghost ghost left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good stuff, works well.

@ghost

ghost commented Jun 20, 2017

Copy link
Copy Markdown

Merging, thanks!

@ghost ghost merged commit 84011fb into arsenetar:master Jun 20, 2017
This pull request was closed.
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

Successfully merging this pull request may close these issues.

1 participant