Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 22 additions & 4 deletions qt/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -484,11 +484,11 @@ def _create_actions(self):
_('Use checksums for file change detection.')),
'act_pause_take_snapshot': (
icon.PAUSE, _('Pause backup process'),
lambda: os.kill(self.snapshots.pid(), signal.SIGSTOP), None,
lambda: self._signal_snapshot_process(signal.SIGSTOP), None,
None),
'act_resume_take_snapshot': (
icon.RESUME, _('Resume backup process'),
lambda: os.kill(self.snapshots.pid(), signal.SIGCONT), None,
lambda: self._signal_snapshot_process(signal.SIGCONT), None,
None),
'act_stop_take_snapshot': (
icon.STOP, _('Stop backup process'),
Expand Down Expand Up @@ -1871,12 +1871,30 @@ def _create_backup(self, checksum: bool) -> None:
backintime.takeSnapshotAsync(self.config, checksum=checksum)
self._update_backup_status(True)

def _signal_snapshot_process(self, sig: signal.Signals) -> bool:
pid = self.snapshots.pid()

if not tools.processAlive(pid):
self._update_backup_status(True)
return False
Comment on lines +1877 to +1879

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

If you don't have any objects, I suggest to remove that part.
The following try-except-block is enough for this rare case.


try:
os.kill(pid, sig)
except ProcessLookupError:
logger.debug(
f'Ignoring signal {sig} for vanished snapshot process {pid}.')
Comment on lines +1884 to +1885

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

No need for debug output on this event.

self._update_backup_status(True)
return False

return True

def _slot_backup_stop(self):
os.kill(self.snapshots.pid(), signal.SIGKILL)
if self._signal_snapshot_process(signal.SIGKILL):
self.snapshots.setTakeSnapshotMessage(0, 'Backup terminated')

self.act_stop_take_snapshot.setEnabled(False)
self.act_pause_take_snapshot.setEnabled(False)
self.act_resume_take_snapshot.setEnabled(False)
self.snapshots.setTakeSnapshotMessage(0, 'Backup terminated')

# |---------|
# | Restore |
Expand Down