本文整理汇总了Python中lock.Lock.is_same_file方法的典型用法代码示例。如果您正苦于以下问题:Python Lock.is_same_file方法的具体用法?Python Lock.is_same_file怎么用?Python Lock.is_same_file使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类lock.Lock
的用法示例。
在下文中一共展示了Lock.is_same_file方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: daemonize
# 需要导入模块: from lock import Lock [as 别名]
# 或者: from lock.Lock import is_same_file [as 别名]
def daemonize(args, callback):
with DaemonContext():
from touchandgo.logger import log_set_up
log_set_up(True)
log = logging.getLogger('touchandgo.daemon')
log.info("running daemon")
create_process = False
lock = Lock(LOCKFILE, os.getpid(), args.name, args.sea_ep[0],
args.sea_ep[1], args.port)
if lock.is_locked():
log.debug("lock active")
lock_pid = lock.get_pid()
if not lock.is_same_file(args.name, args.sea_ep[0],
args.sea_ep[1]) \
or not is_process_running(lock_pid):
try:
log.debug("killing process %s" % lock_pid)
os.kill(lock_pid, signal.SIGQUIT)
except OSError:
pass
except TypeError:
pass
lock.break_lock()
create_process = True
else:
create_process = True
if create_process:
log.debug("creating proccess")
lock.acquire()
callback()
lock.release()
else:
log.debug("same daemon process")
示例2: daemonize
# 需要导入模块: from lock import Lock [as 别名]
# 或者: from lock.Lock import is_same_file [as 别名]
def daemonize(args, callback):
with DaemonContext():
create_process = False
lock = Lock(LOCKFILE, os.getpid(), args.name, args.sea_ep[0],
args.sea_ep[1], args.port)
if lock.is_locked():
lock_pid = lock.get_pid()
if not lock.is_same_file(args.name, args.sea_ep[0],
args.sea_ep[1]) \
or not is_process_running(lock_pid):
try:
os.kill(lock_pid, signal.SIGQUIT)
except OSError:
pass
except TypeError:
pass
lock.break_lock()
create_process = True
else:
create_process = True
if create_process:
lock.acquire()
callback(args.name, season=args.sea_ep[0], episode=args.sea_ep[1],
serve=True, port=args.port)
lock.release()