try:
    with open('/var/run/foo.lock', 'w'):
        check_call('/path/to/binary')
finally:
    os.remove('/var/run/foo.lock')
Is there a way to prevent two Python programs from executing the same binary at the same time?