creates pid file and writes os.pid() in there

def create_pid_file(process_name):
    """ creates pid file and writes os.pid() in there """
    pid_filename = get_pid_filename(process_name)
    try:
        with open(pid_filename, mode='w') as pid_file:
            pid_file.write(str(os.getpid()))
    except Exception as e:
        print('Unable to create pid file at: {0}, because of: {1}'.format(pid_filename, e),
              file=sys.stderr)