mirror of https://github.com/borgbase/vorta
Improve cancelling Borg process (#786)
* Try SIGINT and then SIGTERM * Minor: shlex.join needs Python >=3.8
This commit is contained in:
parent
38cd7cd2e6
commit
09e978220f
|
@ -10,7 +10,7 @@ import logging
|
|||
from collections import namedtuple
|
||||
from PyQt5 import QtCore
|
||||
from PyQt5.QtWidgets import QApplication
|
||||
from subprocess import Popen, PIPE
|
||||
from subprocess import Popen, PIPE, TimeoutExpired
|
||||
|
||||
from vorta.i18n import trans_late
|
||||
from vorta.models import EventLogModel, BackupProfileMixin
|
||||
|
@ -269,9 +269,17 @@ class BorgThread(QtCore.QThread, BackupProfileMixin):
|
|||
mutex.unlock()
|
||||
|
||||
def cancel(self):
|
||||
"""
|
||||
First try to terminate the running Borg process with SIGINT (Ctrl-C),
|
||||
if this fails, use SIGTERM.
|
||||
"""
|
||||
if self.isRunning():
|
||||
mutex.unlock()
|
||||
self.process.send_signal(signal.SIGINT)
|
||||
try:
|
||||
self.process.wait(timeout=3)
|
||||
except TimeoutExpired:
|
||||
self.process.terminate()
|
||||
mutex.unlock()
|
||||
self.terminate()
|
||||
|
||||
def process_result(self, result):
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
import plistlib
|
||||
import shlex
|
||||
import subprocess
|
||||
import xml
|
||||
from typing import Optional, Iterator
|
||||
|
@ -71,7 +70,7 @@ def call_ipconfig_getpacket(bsd_device):
|
|||
try:
|
||||
return subprocess.check_output(cmd)
|
||||
except subprocess.CalledProcessError:
|
||||
logger.debug("Command %s failed", shlex.join(cmd))
|
||||
logger.debug("Command %s failed", ' '.join(cmd))
|
||||
return b''
|
||||
|
||||
|
||||
|
@ -80,4 +79,4 @@ def call_networksetup_listallhardwareports():
|
|||
try:
|
||||
return subprocess.check_output(cmd)
|
||||
except subprocess.CalledProcessError:
|
||||
logger.debug("Command %s failed", shlex.join(cmd))
|
||||
logger.debug("Command %s failed", ' '.join(cmd))
|
||||
|
|
Loading…
Reference in New Issue