pythonc++condor

Detecting from within a process whether it is running as an HTCondor job


Could you please let me know if there is a way to detect from within a process whether it is running as an HTCondor job?

I am especially interested in how to do it from python code but a C++ way to do it would be also very helpful.

Example of what I hope to do in python:

if current_process_is_running_as_an_HTCondor_job():
    do_action_1()
else:
    do_action_2()

How can one implement current_process_is_running_as_an_HTCondor_job() ?

Thank you very much for your help!


Solution

  • HTCondor sets a number of environment variables: https://htcondor.readthedocs.io/en/latest/users-manual/services-for-jobs.html

    The existence of any of them would be a good indicator that you are running under Condor.