本文整理汇总了Python中threading.RLock._acquire_restore方法的典型用法代码示例。如果您正苦于以下问题:Python RLock._acquire_restore方法的具体用法?Python RLock._acquire_restore怎么用?Python RLock._acquire_restore使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类threading.RLock
的用法示例。
在下文中一共展示了RLock._acquire_restore方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: CECPEngine
# 需要导入模块: from threading import RLock [as 别名]
# 或者: from threading.RLock import _acquire_restore [as 别名]
#.........这里部分代码省略.........
fen_arr[1] = "b"
fen = " ".join(fen_arr)
print("setboard %s" % fen, file=self.engine)
else:
# Kludge to set black to move, avoiding the troublesome and now
# deprecated "black" command. - Equal to the one xboard uses
self.__tellEngineToStopPlayingCurrentColor()
if board.color == BLACK:
print("a2a3", file=self.engine)
print("edit", file=self.engine)
print("#", file=self.engine)
for color in WHITE, BLACK:
for y, row in enumerate(board.data):
for x, piece in enumerate(row):
if not piece or piece.color != color:
continue
sign = reprSign[piece.sign]
cord = repr(Cord(x,y))
print(sign+cord, file=self.engine)
print("c", file=self.engine)
print(".", file=self.engine)
def _blockTillMove (self):
saved_state = self.boardLock._release_save()
log.debug("_blockTillMove(): acquiring self.movecon lock", extra={"task":self.defname})
self.movecon.acquire()
log.debug("_blockTillMove(): self.movecon acquired", extra={"task":self.defname})
try:
log.debug("_blockTillMove(): doing self.movecon.wait", extra={"task":self.defname})
self.movecon.wait()
finally:
log.debug("_blockTillMove(): releasing self.movecon..", extra={"task":self.defname})
self.movecon.release()
self.boardLock._acquire_restore(saved_state)
#===========================================================================
# Parsing
#===========================================================================
def parseLines (self, engine, lines):
for line in lines:
self.__parseLine(line)
def __parseLine (self, line):
if line[0:1] == "#":
# Debug line which we shall ignore as specified in CECPv2 specs
return
# log.debug("__parseLine: line=\"%s\"" % line.strip(), extra={"task":self.defname})
parts = whitespaces.split(line.strip())
if parts[0] == "pong":
self.lastpong = int(parts[1])
return
# Illegal Move
if parts[0].lower().find("illegal") >= 0:
log.warning("__parseLine: illegal move: line=\"%s\", board=%s" \
% (line.strip(), self.board), extra={"task":self.defname})
if parts[-2] == "sd" and parts[-1].isdigit():
print("depth", parts[-1], file=self.engine)
return
# A Move (Perhaps)
if self.board:
if parts[0] == "move":
示例2: CECPEngine
# 需要导入模块: from threading import RLock [as 别名]
# 或者: from threading.RLock import _acquire_restore [as 别名]
#.........这里部分代码省略.........
if self.features["setboard"]:
self.__tellEngineToStopPlayingCurrentColor()
print >> self.engine, "setboard", board.asFen()
else:
# Kludge to set black to move, avoiding the troublesome and now
# deprecated "black" command. - Equal to the one xboard uses
self.__tellEngineToStopPlayingCurrentColor()
if board.color == BLACK:
print >> self.engine, "a2a3"
print >> self.engine, "edit"
print >> self.engine, "#"
for color in WHITE, BLACK:
for y, row in enumerate(board.data):
for x, piece in enumerate(row):
if not piece or piece.color != color:
continue
sign = reprSign[piece.sign]
cord = repr(Cord(x,y))
print >> self.engine, sign+cord
print >> self.engine, "c"
print >> self.engine, "."
def _blockTillMove (self):
saved_state = self.boardLock._release_save()
log.debug("_blockTillMove(): acquiring self.movecon lock\n", self.defname)
self.movecon.acquire()
log.debug("_blockTillMove(): self.movecon acquired\n", self.defname)
try:
log.debug("_blockTillMove(): doing self.movecon.wait\n", self.defname)
self.movecon.wait()
finally:
log.debug("_blockTillMove(): releasing self.movecon..\n", self.defname)
self.movecon.release()
self.boardLock._acquire_restore(saved_state)
#===========================================================================
# Parsing
#===========================================================================
def parseLines (self, engine, lines):
for line in lines:
self.__parseLine(line)
def __parseLine (self, line):
# log.debug("__parseLine: line=\"%s\"\n" % line.strip(), self.defname)
parts = whitespaces.split(line.strip())
if parts[0] == "pong":
self.lastpong = int(parts[1])
return
# Illegal Move
if parts[0].lower().find("illegal") >= 0:
log.warn("__parseLine: illegal move: line=\"%s\", board=%s" \
% (line.strip(), self.board), self.defname)
if parts[-2] == "sd" and parts[-1].isdigit():
print >> self.engine, "depth", parts[-1]
return
# A Move (Perhaps)
if self.board:
if parts[0] == "move":
movestr = parts[1]
# Old Variation
elif d_plus_dot_expr.match(parts[0]) and parts[1] == "...":
movestr = parts[2]