Execute process with timeout

    0

    3

    Python public recipes

    The code creates a new process and calls the open() function on it. It then sets a timeout and calls the wait() function. If the wait() function returns false, the code calls the kill() function to end the process.

    import subprocess
    
    process = subprocess.Popen(cmd_args)
    try:
      process.wait(timeout=timeout_seconds)
    except subprocess.TimeoutExpired:
      process.kill()
      process.wait()
    Codiga Logo
    Codiga Hub
    • Rulesets
    • Playground
    • Snippets
    • Cookbooks
    Legal
    • Security
    • Privacy Policy
    • Code Privacy
    • Terms of Service
    soc-2 icon

    We are SOC-2 Compliance Certified

    G2 high performer medal

    Codiga – All rights reserved 2022.