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

modifying cancellation #1368

Merged
merged 1 commit into from
Aug 15, 2023
Merged
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
15 changes: 1 addition & 14 deletions server/dive_tasks/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import subprocess
from subprocess import Popen
import tempfile
import time
from typing import List, Tuple
from urllib import request
from urllib.parse import urlencode, urljoin
Expand Down Expand Up @@ -88,17 +87,6 @@ def stream_subprocess(
stdout=subprocess.PIPE,
stderr=stderr_file,
)
while process.poll() is None: # while there is no return code
time.sleep(60) # every minute we check to see if the process is in the cancelling state
manager.refreshStatus()
print(manager.status)
if manager.status == JobStatus.CANCELING:
manager.write('Killing subprocess')
process.send_signal(signal.SIGTERM)
process.send_signal(signal.SIGKILL)
time.sleep(10)
# VIAME doesn't respond to the above signals we need to interrupt
process.send_signal(signal.SIGINT)

if process.stdout is None:
raise RuntimeError("Stdout must not be none")
Expand All @@ -112,12 +100,11 @@ def stream_subprocess(

# Cancel the subprocess if the status is cancelling
# note this only checks when there is stdout from the subprocess
manager.refreshStatus()
if check_canceled(task, context, force=False) or manager.status == JobStatus.CANCELING:
# Can never be sure what signal a process will respond to.
process.send_signal(signal.SIGTERM)
process.send_signal(signal.SIGKILL)
# VIAME doesn't respond to the above signals we need to interrupt
time.sleep(10)
process.send_signal(signal.SIGINT)
# flush logs
manager._flush()
Expand Down
Loading