本文整理汇总了Python中queue.Queue._put方法的典型用法代码示例。如果您正苦于以下问题:Python Queue._put方法的具体用法?Python Queue._put怎么用?Python Queue._put使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类queue.Queue
的用法示例。
在下文中一共展示了Queue._put方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _put
# 需要导入模块: from queue import Queue [as 别名]
# 或者: from queue.Queue import _put [as 别名]
def _put(self, xxx_todo_changeme):
# Only consider re-evaluation if we are still on the same eval
# session.
(eval_sess, is_reeval) = xxx_todo_changeme
if is_reeval and self._curr_eval_sess is not eval_sess:
return
replace = True
if hasattr(eval_sess, "ctlr") and eval_sess.ctlr and eval_sess.ctlr.keep_existing:
# Allow multiple eval sessions; currently used for variable
# highlighting (bug 80095), may pick up additional uses. Note that
# these sessions can still get wiped out by a single replace=False
# caller.
replace = False
if replace:
# We only allow *one* eval session at a time.
# - Drop a possible accumulated eval session.
if len(self.queue):
self.queue.clear()
## - Abort the current eval session.
if not is_reeval and self._curr_eval_sess is not None:
self._curr_eval_sess.ctlr.abort()
# Lazily start the eval thread.
if not self.isAlive():
self.start()
Queue._put(self, (eval_sess, is_reeval))
if replace:
assert len(self.queue) == 1
示例2: matrix_bfs
# 需要导入模块: from queue import Queue [as 别名]
# 或者: from queue.Queue import _put [as 别名]
def matrix_bfs(initialState):
# initialize datastructures
knownSet = dict()
toBeVisited = Queue()
# give the algorithm initial parameters
knownSet[initialState.__hash__()] = 1
toBeVisited._put(initialState)
while not(toBeVisited.empty()):
global count
count += 1
#remove a state from the front of the queue
curState = toBeVisited.get()
global endPos
if not(curState.curPosition.__eq__(endPos)):
knownSet[curState.__hash__()] = 1
#check to see if it's the final state, if so flag, break, and print
if(is_final_state(curState)):
global bfs_complete_flag
bfs_complete_flag = 1
break
#curState.__repr__()
#print(curState.curPosition.row, curState.curPosition.column)
#print()
#get the curState's neighbors, and queue them up if they haven't been visited yet
for adj in curState.get_adjacent_states():
if not(adj.__hash__ in knownSet):
toBeVisited.put(adj)
示例3: Bot
# 需要导入模块: from queue import Queue [as 别名]
# 或者: from queue.Queue import _put [as 别名]
class Bot(object):
def __init__(self, me, job):
self.targets = Queue()
self.me = me
self.position = 1
pushes = job.split()
for i in range(len(pushes)):
if pushes[i] == me: self.targets._put(pushes[i+1])
def move(self, who):
if self.targets.empty(): return False
target = int(self.targets.queue[0])
if self.position == target:
if self.me == who:
self.targets.get()
return True
elif self.position < target:
self.position += 1
else:
self.position -= 1
return False
示例4: _put
# 需要导入模块: from queue import Queue [as 别名]
# 或者: from queue.Queue import _put [as 别名]
def _put(self, item):
if item not in self.all_items:
Queue._put(self, item)
self.all_items.add(item)
示例5: _put
# 需要导入模块: from queue import Queue [as 别名]
# 或者: from queue.Queue import _put [as 别名]
def _put(self, item):
Queue._put(self, item)
self.sort()