本文整理汇总了Python中queue.LifoQueue.qsize方法的典型用法代码示例。如果您正苦于以下问题:Python LifoQueue.qsize方法的具体用法?Python LifoQueue.qsize怎么用?Python LifoQueue.qsize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类queue.LifoQueue
的用法示例。
在下文中一共展示了LifoQueue.qsize方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: print
# 需要导入模块: from queue import LifoQueue [as 别名]
# 或者: from queue.LifoQueue import qsize [as 别名]
print("{}/{} users will be updated.".format(n_existed, i - n_existed))
####################
# dispatch threads
####################
dq_thread = Thread(target = dq_helper, kwargs = {'root': root})
dq_thread.daemon = True
dq_thread.start()
uq_thread = Thread(target = uq_helper, kwargs = {'root': root})
uq_thread.daemon = True
uq_thread.start()
for key in keys:
if tq.qsize() == 0: break
t = Thread(target = crawler,
kwargs ={'key': key,
'name': '{min}:{max}-{no:03}'.format(min = min(RG), max = max(RG), no = keys.index(key)),
'rest_url':'users/lookup'})
t.daemon = True
time.sleep(2)
t.start()
tq.join()
dq.put(None)
uq.put(None)
print("Complete!")
示例2: ZipFile
# 需要导入模块: from queue import LifoQueue [as 别名]
# 或者: from queue.LifoQueue import qsize [as 别名]
continue
need_optimize = False
try:
cursor_id = None
with ZipFile('{}/{}/{}.zip'.format(root, str(item)[:3], item), 'r') as zf:
names = list(int(name) for name in zf.namelist())
if len(names) == 0: raise BadZipfile
names.sort(reverse = UPDATE_FORWARD)
cursor_id = names[0] - (0 if UPDATE_FORWARD else 1)
n_existed = n_existed + 1
need_optimize = (zf.getinfo(min(zf.namelist())).compress_type != ZIP_LZMA or len(zf.namelist()) > 10) and (i % OPTIMIZE_ZIP == 0) and (zf.getinfo(min(zf.namelist())).file_size < 169736650)
with stout_lock:
print('\r[{:<4}]<({:^12}){}[{}]:{:3.1f}hr'.format(tq.qsize(),
str(item) * need_optimize,
'|' * round((len(inlist) - i)/len(inlist)*65),
len(inlist) - i,
(len(inlist) - i) * speed / 3600),
flush = True, end = '\r')
if need_optimize:
with ZipFile('{}/{}/{}'.format(root, str(item)[:3], item) +'.lzma',
mode = 'w', compression = ZIP_LZMA) as zout:
content = ','.encode('utf-8').join(zf.read(str(name))[1:-1] for name in sorted(names, reverse = True))
content = '['.encode('utf-8') + content + ']'.encode('utf-8')
zout.writestr(str(max(names)), content, ZIP_LZMA)
except IOError: pass
except BadZipfile: