Python asyncio.queues() Examples

The following are 3 code examples of asyncio.queues(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module asyncio , or try the search function .
Example #1
Source File: music.py    From apex-sigma-core with GNU General Public License v3.0 5 votes vote down vote up
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) 
Example #2
Source File: music.py    From apex-sigma-core with GNU General Public License v3.0 5 votes vote down vote up
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 
Example #3
Source File: idxdumper.py    From dumpall with MIT License 5 votes vote down vote up
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