Python源码示例:asyncio.queues()

示例1
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
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
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