本文整理汇总了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