Code Monkey home page Code Monkey logo

Comments (2)

prashantmital avatar prashantmital commented on September 22, 2024

After some more digging, it seems that using the CTRL_BREAK_EVENT signal is the right way to kill process groups on Windows. The following combination of scripts works:

  1. pyscript.py analogous to 'the framework', i.e. astrolabe):
import subprocess
import os
import signal
import sys
import time


cmd = subprocess.Popen([sys.executable, "bgproc.py"],
        creationflags=subprocess.CREATE_NEW_PROCESS_GROUP,
        stdout=subprocess.PIPE, stderr=subprocess.PIPE)
time.sleep(2)
os.kill(cmd.pid, signal.CTRL_BREAK_EVENT)
stdout, stderr = cmd.communicate(timeout=10)

print("stdout: {}".format(stdout))
print("stderr: {}".format(stderr))
print("exit code: {}".format(cmd.returncode))
  1. bgproc.py (analogous to a driver workload executor script):
import signal

print("hello world")

def cleanup(signum, frame):
    print("caught ctrl-break!")
    exit(0)

signal.signal(signal.SIGBREAK, cleanup)

while True:
    pass

exit(0)

This works as expected:

$ C:/python/Python37/python.exe pyscript.py
stdout: b'hello world\r\ncaught ctrl-break!\r\n'
stderr: b''
exit code: 0

from drivers-atlas-testing.

prashantmital avatar prashantmital commented on September 22, 2024

With #32 and #30 done, this mostly boils down to document this change in the expected behavior of workload executors written for windows. Adding the documentation tag and updating the issue description accordingly.

from drivers-atlas-testing.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.