Skip to content

Consider wrapping subprocess calls in try/except blocks #24

Open
@alexpreynolds

Description

@alexpreynolds

subprocess.run("scancel {}".format(allJobIDs), shell=True)

Using a try/except block where you use subprocess calls can help with catching local issues with running command-line tools outside of Python:

try:
    subprocess.run("scancel {}".format(allJobIDs), shell=True)
except subprocess.CalledProcessError as e:
    # handle error...

Certain error codes might have to do with the binary not being found, or in the case of scancel, one or more job IDs passed to it might not found associated with any jobs internally, etc. Better handling of errors can help end users catch odd problems, or help with debugging.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions