diff --git a/discordbot.py b/discordbot.py index 6b1032b8..f9f70201 100644 --- a/discordbot.py +++ b/discordbot.py @@ -39,7 +39,7 @@ voice_queue = [] voice_playing = None # Init the executor -executor = concurrent.futures.ThreadPoolExecutor(max_workers=1) +executor = concurrent.futures.ThreadPoolExecutor(max_workers=3) class Video: def __init__(self): @@ -289,9 +289,6 @@ async def on_message(message: discord.Message): if voice_player is None: await client.send_message(message.channel, f"ℹ Non c'è nulla in riproduzione al momento.") return - voice_queue = [] - voice_player.stop() - voice_player = None await client.send_message(message.channel, f"ℹ Ora in riproduzione in <#{voice_client.channel.id}>:", embed=voice_playing.create_embed()) elif message.content.startswith("!queue"): if voice_player is None: diff --git a/test_executor.py b/test_executor.py new file mode 100644 index 00000000..954a0274 --- /dev/null +++ b/test_executor.py @@ -0,0 +1,17 @@ +import asyncio +import functools +import concurrent.futures + +loop = asyncio.get_event_loop() +executor = concurrent.futures.ThreadPoolExecutor(max_workers=1) + +async def call_me(): + await loop.run_in_executor(executor, functools.partial(print, "ciao")) + return + +async def spam_calls(): + while True: + asyncio.ensure_future(call_me()) + await asyncio.sleep(1) + +loop.run_until_complete(spam_calls()) \ No newline at end of file