本文整理匯總了Python中asyncio.queues方法的典型用法代碼示例。如果您正苦於以下問題:Python asyncio.queues方法的具體用法?Python asyncio.queues怎麽用?Python asyncio.queues使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類asyncio
的用法示例。
在下文中一共展示了asyncio.queues方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: __init__
# 需要導入模塊: import asyncio [as 別名]
# 或者: from asyncio import queues [as 別名]
def __init__(self, bot):
"""
:param bot: The core client class.
:type bot: sigma.core.sigma.ApexSigma
"""
self.bot = bot
self.db = bot.db
self.loop = asyncio.get_event_loop()
self.threads = ThreadPoolExecutor()
self.queues = {}
self.currents = {}
self.repeaters = []
self.ytdl_params = ytdl_params
self.ytdl = youtube_dl.YoutubeDL(self.ytdl_params)
示例2: get_queue
# 需要導入模塊: import asyncio [as 別名]
# 或者: from asyncio import queues [as 別名]
def get_queue(self, guild_id: int):
"""
Gets a guild's queue.
If the guild doesn't have one, it'll be generated.
:param guild_id: The Guild ID.
:type guild_id: int
:return:
:rtype: asyncio.Queue
"""
queue = self.queues.get(guild_id, Queue())
self.queues.update({guild_id: queue})
return queue
示例3: start
# 需要導入模塊: import asyncio [as 別名]
# 或者: from asyncio import queues [as 別名]
def start(self):
""" 入口方法 """
# queue必須創建在run()方法內 https://stackoverflow.com/questions/53724665/using-queues-results-in-asyncio-exception-got-future-future-pending-attached
self.targets_q = Queue() # url, name
await self.targets_q.put((self.url, "index"))
self.running = True
tasks = []
for i in range(self.task_count):
tasks.append(asyncio.create_task(self.dump()))
for t in tasks:
await t