本文整理汇总了Python中Queue.Full方法的典型用法代码示例。如果您正苦于以下问题:Python Queue.Full方法的具体用法?Python Queue.Full怎么用?Python Queue.Full使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Queue
的用法示例。
在下文中一共展示了Queue.Full方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: sendHciCommand
# 需要导入模块: import Queue [as 别名]
# 或者: from Queue import Full [as 别名]
def sendHciCommand(self, opcode, data, timeout=2):
"""
Send an arbitrary HCI packet by pushing a send-task into the
sendQueue. This function blocks until the response is received
or the timeout expires. The return value is the Payload of the
HCI Command Complete Event which was received in response to
the command or None if no response was received within the timeout.
"""
queue = Queue.Queue(1)
try:
self.sendQueue.put((opcode, data, queue), timeout=timeout)
return queue.get(timeout=timeout)
except Queue.Empty:
log.warn("sendHciCommand: waiting for response timed out!")
return None
except Queue.Full:
log.warn("sendHciCommand: send queue is full!")
return None
示例2: put
# 需要导入模块: import Queue [as 别名]
# 或者: from Queue import Full [as 别名]
def put(self, item, block=True, timeout=None):
"""Put an item into the requeue.
Args:
item: An item to add to the requeue.
block: Whether to block if the requeue is full.
timeout: Maximum on how long to wait until the queue is non-full.
Raises:
Queue.Full if the queue is full and the timeout expires.
"""
def PutAction():
self.queue.put(item, block=False)
self._DoWithTimeout(PutAction,
Queue.Full,
self.get_cond,
self.put_cond,
self.lock,
timeout=timeout,
block=block)
示例3: reput
# 需要导入模块: import Queue [as 别名]
# 或者: from Queue import Full [as 别名]
def reput(self, item, block=True, timeout=None):
"""Re-put an item back into the requeue.
Re-putting an item does not increase the number of outstanding
tasks, so the reput item should be uniquely associated with an
item that was previously removed from the requeue and for which
TaskDone has not been called.
Args:
item: An item to add to the requeue.
block: Whether to block if the requeue is full.
timeout: Maximum on how long to wait until the queue is non-full.
Raises:
Queue.Full is the queue is full and the timeout expires.
"""
def ReputAction():
self.requeue.put(item, block=False)
self._DoWithTimeout(ReputAction,
Queue.Full,
self.get_cond,
self.put_cond,
self.lock,
timeout=timeout,
block=block)
示例4: _queue_connection
# 需要导入模块: import Queue [as 别名]
# 或者: from Queue import Full [as 别名]
def _queue_connection(self, cnx):
"""Put connection back in the queue
This method is putting a connection back in the queue. It will not
acquire a lock as the methods using _queue_connection() will have it
set.
Raises PoolError on errors.
"""
if not isinstance(cnx, MySQLConnection):
raise errors.PoolError(
"Connection instance not subclass of MySQLConnection.")
try:
self._cnx_queue.put(cnx, block=False)
except queue.Full:
errors.PoolError("Failed adding connection; queue is full")
示例5: run
# 需要导入模块: import Queue [as 别名]
# 或者: from Queue import Full [as 别名]
def run(self):
while True:
resource = {}
resource['url'] = '{0}{1}'.format(self.url, self.offset)
resource['type'] = self.type
try:
self.q.put(resource, block=True, timeout=3)
except Queue.Full:
pass
else:
print '{0} now in queue'.format(self.offset)
if self.offset < self.pages:
self.offset += 1
else:
break
print '{0} finish produce works'.format(self.name)
示例6: serve
# 需要导入模块: import Queue [as 别名]
# 或者: from Queue import Full [as 别名]
def serve(self, socket):
echo_queue = queue.Queue(2)
echo_thread = threading.Thread(target=self.echo,
args=(socket, echo_queue))
echo_thread.start()
peer = socket.getpeername()
log.info("serving connection from sap {0}".format(peer))
while socket.poll("recv"):
data = socket.recv()
if data is None:
break
log.info("rcvd {0} byte from sap {1}".format(len(data), peer))
if echo_queue.full():
socket.setsockopt(nfc.llcp.SO_RCVBSY, True)
echo_queue.put(data)
log.info("remote peer {0} closed closed connection".format(peer))
try:
echo_queue.put_nowait(int(0))
except queue.Full:
pass
echo_thread.join()
socket.close()
log.info("serve thread terminated")
示例7: add_event_to_queue
# 需要导入模块: import Queue [as 别名]
# 或者: from Queue import Full [as 别名]
def add_event_to_queue(self, event_type, event_data, player_state):
"""Adds an event in the queue of events to be processed"""
videoid = common.VideoId.from_dict(event_data['videoid'])
# pylint: disable=unused-variable
previous_data, previous_player_state = self.cache_data_events.get(videoid.value, ({}, None))
manifest = get_manifest(videoid)
url = manifest['links']['events']['href']
if previous_data.get('xid') in self.banned_events_ids:
common.warn('EVENT [{}] - Not added to the queue. The xid {} is banned due to a previous failed request',
event_type, previous_data.get('xid'))
return
from resources.lib.services.msl.msl_request_builder import MSLRequestBuilder
request_data = MSLRequestBuilder.build_request_data(url,
self._build_event_params(event_type,
event_data,
player_state,
manifest))
try:
self.queue_events.put_nowait(Event(request_data, event_data))
except queue.Full:
common.warn('EVENT [{}] - Not added to the queue. The event queue is full.', event_type)
示例8: _proc_loop
# 需要导入模块: import Queue [as 别名]
# 或者: from Queue import Full [as 别名]
def _proc_loop(proc_id, alive, queue, fn):
"""
Thread loop for generating data
Parameters
----------
proc_id: int
Process id
alive: multiprocessing.Value
variable for signaling whether process should continue or not
queue: multiprocessing.Queue
queue for passing data back
fn: function
function object that returns a sample to be pushed into the queue
"""
print("proc {} started".format(proc_id))
try:
while alive.value:
data = fn()
put_success = False
while alive.value and not put_success:
try:
queue.put(data, timeout=0.5)
put_success = True
except QFullExcept:
# print("Queue Full")
pass
except KeyboardInterrupt:
print("W: interrupt received, stopping process {} ...".format(proc_id))
print("Closing process {}".format(proc_id))
queue.close()
示例9: add_nameserver
# 需要导入模块: import Queue [as 别名]
# 或者: from Queue import Full [as 别名]
def add_nameserver(self, nameserver):
keep_trying = True
while not self.time_to_die and keep_trying:
try:
self.resolver_q.put(nameserver, timeout = 1)
trace("Added nameserver:", nameserver)
keep_trying = False
except Exception as e:
if type(e) == Queue.Full or str(type(e)) == "<class 'queue.Full'>":
keep_trying = True
示例10: _put_conn
# 需要导入模块: import Queue [as 别名]
# 或者: from Queue import Full [as 别名]
def _put_conn(self, conn):
"""
Put a connection back into the pool.
:param conn:
Connection object for the current host and port as returned by
:meth:`._new_conn` or :meth:`._get_conn`.
If the pool is already full, the connection is closed and discarded
because we exceeded maxsize. If connections are discarded frequently,
then maxsize should be increased.
If the pool is closed, then the connection will be closed and discarded.
"""
try:
self.pool.put(conn, block=False)
return # Everything is dandy, done.
except AttributeError:
# self.pool is None.
pass
except Full:
# This should never happen if self.block == True
log.warning(
"Connection pool is full, discarding connection: %s" %
self.host)
# Connection never got put back into the pool, close it.
if conn:
conn.close()
示例11: __exit__
# 需要导入模块: import Queue [as 别名]
# 或者: from Queue import Full [as 别名]
def __exit__(self, extype, exvalue, traceback):
# if we had a MySQL related error we try to rollback the cursor.
if extype is mysql.MySQLError:
self.cursor.rollback()
self.cursor.close()
self.conn.commit()
# Put it back on the queue
try:
self._cache.put_nowait(self.conn)
except Queue.Full:
self.conn.close()
示例12: _put_conn
# 需要导入模块: import Queue [as 别名]
# 或者: from Queue import Full [as 别名]
def _put_conn(self, conn):
"""
Put a connection back into the pool.
:param conn:
Connection object for the current host and port as returned by
:meth:`._new_conn` or :meth:`._get_conn`.
If the pool is already full, the connection is closed and discarded
because we exceeded maxsize. If connections are discarded frequently,
then maxsize should be increased.
If the pool is closed, then the connection will be closed and discarded.
"""
try:
self.pool.put(conn, block=False)
return # Everything is dandy, done.
except AttributeError:
# self.pool is None.
pass
except Full:
# This should never happen if self.block == True
log.warning(
"Connection pool is full, discarding connection: %s",
self.host)
# Connection never got put back into the pool, close it.
if conn:
conn.close()
示例13: SubmitItem
# 需要导入模块: import Queue [as 别名]
# 或者: from Queue import Full [as 别名]
def SubmitItem(self, item, block=True, timeout=0.0):
"""Submit a WorkItem to the AdaptiveThreadPool.
Args:
item: A WorkItem instance.
block: Whether to block on submitting if the submit queue is full.
timeout: Time wait for room in the queue if block is True, 0.0 to
block indefinitely.
Raises:
Queue.Full if the submit queue is full.
"""
self.requeue.put(item, block=block, timeout=timeout)
示例14: _put_conn
# 需要导入模块: import Queue [as 别名]
# 或者: from Queue import Full [as 别名]
def _put_conn(self, conn):
"""
Put a connection back into the pool.
:param conn:
Connection object for the current host and port as returned by
:meth:`._new_conn` or :meth:`._get_conn`.
If the pool is already full, the connection is closed and discarded
because we exceeded maxsize. If connections are discarded frequently,
then maxsize should be increased.
If the pool is closed, then the connection will be closed and discarded.
"""
try:
self.pool.put(conn, block=False)
return # Everything is dandy, done.
except AttributeError:
# self.pool is None.
pass
except Full:
# This should never happen if self.block == True
log.warning(
"Connection pool is full, discarding connection: %s" %
self.host)
# Connection never got put back into the pool, close it.
if conn:
conn.close()
示例15: FindAllUids
# 需要导入模块: import Queue [as 别名]
# 或者: from Queue import Full [as 别名]
def FindAllUids(self,htmlContent,surfedUid,uidQueue,fp1):
print('In Find All uids')#action-type=\"follow\" action-data=\"refer_sort=followlist&refer_flag=followlist&uid=
PatUid=re.compile('(<li class=\\\\"follow_item S_line2\\\\" action-type=\\\\"itemClick\\\\" action-data=\\\\"uid=)(\\d+)'.encode('utf8'))
for m in PatUid.finditer(htmlContent):
mUid=m.group(2)
#print mUid
if mUid not in surfedUid:
if uidQueue.put(mUid,True)==Queue.Full:
print("The urlQueue is Full,Stop spiding")
return
fp1.write(' '.encode('utf8')+mUid)
PatNextPage=re.compile('(<a bpfilter=\\\\"page\\\\" class=\\\\"page next S_txt1 S_line1\\\\" href=\\\\")(\\\\/p\\\\/\\d+\\\\/.*)("><span>下一页<\\\\/span><\\\\/a>)'.decode('gbk').encode('utf8'))
result=PatNextPage.search(htmlContent)
while result!=None:#存在下一页
print("Next Page")#系统问题,新浪微博规定只能浏览5页
result=result.group(2)
result=re.sub('\\\\','',result)
result='http://weibo.com'+result
time.sleep(1)
htmlContent=urllib2.urlopen(result).read()
PatUid=re.compile('(<li class=\\\\"follow_item S_line2\\\\" action-type=\\\\"itemClick\\\\" action-data=\\\\"uid=)(\\d+)'.encode('utf8'))
PatUid.search(htmlContent)
for m in PatUid.finditer(htmlContent):
#print mUid
mUid=m.group(2)
if mUid not in surfedUid:
if uidQueue.put(mUid,True)==Queue.Full:
print("The urlQueue is Full,Stop spiding")
return
fp1.write(' '.encode('utf8')+mUid)
result=PatNextPage.search(htmlContent)