mirror of
https://github.com/borgbase/vorta
synced 2025-01-02 21:25:48 +00:00
terminate process
This commit is contained in:
parent
d721011c90
commit
c8ccd16dad
1 changed files with 11 additions and 8 deletions
|
@ -113,16 +113,19 @@ def repo_id(self):
|
||||||
return self.site_id
|
return self.site_id
|
||||||
|
|
||||||
def cancel(self):
|
def cancel(self):
|
||||||
logger.debug("Cancel job on site %s", self.site_id)
|
logger.debug("Cancelling job on site %s", self.site_id)
|
||||||
if self.process is not None:
|
if self.process is not None:
|
||||||
self.process.send_signal(signal.SIGINT)
|
self.terminate_process(self.process)
|
||||||
|
|
||||||
|
def terminate_process(self, process):
|
||||||
|
process.send_signal(signal.SIGINT)
|
||||||
|
try:
|
||||||
|
process.wait(timeout=3)
|
||||||
|
except TimeoutExpired:
|
||||||
try:
|
try:
|
||||||
self.process.wait(timeout=3)
|
os.killpg(os.getpgid(process.pid), signal.SIGTERM)
|
||||||
except TimeoutExpired:
|
except ProcessLookupError:
|
||||||
try:
|
pass
|
||||||
os.killpg(os.getpgid(self.process.pid), signal.SIGTERM)
|
|
||||||
except ProcessLookupError:
|
|
||||||
pass
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def prepare(cls, profile):
|
def prepare(cls, profile):
|
||||||
|
|
Loading…
Reference in a new issue