Did I find the right examples for you? yes no

All Samples(2)  |  Call(1)  |  Derive(0)  |  Import(1)
Writes our PID to *path*.

        def write_pid(path):
    """Writes our PID to *path*."""
    try:
        pid = os.getpid()
        with io.open(path, mode='w', encoding='utf-8') as pidfile:
            # Get a non-blocking exclusive lock
            fcntl.flock(pidfile.fileno(), fcntl.LOCK_EX | fcntl.LOCK_NB)
            pidfile.seek(0)
            pidfile.truncate(0)
            pidfile.write(unicode(pid))
    except:
        logging.error(_("Could not write PID file: %s") % path)
        raise # This raises the original exception
    finally:
        try:
            pidfile.close()
        except:
            pass
        


src/g/a/GateOne-HEAD/gateone/core/server.py   GateOne(Download)
from .utils import merge_handlers, none_fix, convert_to_timedelta, short_hash
from .utils import json_encode, recursive_chown, ChownError, get_or_cache
from .utils import write_pid, read_pid, remove_pid, drop_privileges
from .utils import check_write_permissions, get_applications, valid_hostname
from .utils import total_seconds, MEMO
        if uid != os.getuid():
            drop_privileges(uid, gid, [tty_gid])
        write_pid(go_settings['pid_file'])
        pid = read_pid(go_settings['pid_file'])
        logger.info(_("Process running with pid " + pid))