本文整理汇总了Python中threading.Thread.consumed_events方法的典型用法代码示例。如果您正苦于以下问题:Python Thread.consumed_events方法的具体用法?Python Thread.consumed_events怎么用?Python Thread.consumed_events使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类threading.Thread
的用法示例。
在下文中一共展示了Thread.consumed_events方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: long_poll_generator
# 需要导入模块: from threading import Thread [as 别名]
# 或者: from threading.Thread import consumed_events [as 别名]
def long_poll_generator(box_events, uploaded_file, request):
# pylint:disable=redefined-outer-name
generator = box_events.generate_events_with_long_polling(stream_position=0)
def long_poll():
for event in generator:
long_poll_thread.events.append(event)
long_poll_thread.event_ready.set()
if long_poll_thread.should_stop_polling:
return
long_poll_thread.consumed_events.wait()
long_poll_thread.consumed_events.clear()
long_poll_thread = Thread(target=long_poll)
long_poll_thread.should_stop_polling = False
long_poll_thread.events = []
long_poll_thread.event_ready = Event()
long_poll_thread.consumed_events = Event()
long_poll_thread.start()
def fin():
long_poll_thread.should_stop_polling = True
uploaded_file.delete()
long_poll_thread.event_ready.wait()
generator.close()
long_poll_thread.join()
request.addfinalizer(fin)
return long_poll_thread