from lockfile import AlreadyLocked
pidfile = PIDLockFile('/var/run/mydaemon.pid', timeout=-1)
try:
    pidfile.acquire()
except AlreadyLocked:
    pass
python-daemon context fails to start when a stale PID file is present