Python-socketio: I get "NotImplementedError" using the asynchronous version of socketio

Created on 31 Aug 2020  路  9Comments  路  Source: miguelgrinberg/python-socketio

Hi @miguelgrinberg
I am implementing socketio inside a discord bot.
I have to use the asynchronous version of socketio because discord.py is asynchronous.
Using the synchronous version of socketio everything works fine, when I use the asynchronous version the following error occurs:

Ignoring exception in command verify:
Traceback (most recent call last):
  File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\lib\site-packages\discord\ext\commands\core.py", line 85, in wrapped
    ret = await coro(*args, **kwargs)
  File "C:\Users\gatto\OneDrive\Desktop\Python\Bot Discord CG\sub_verify.py", line 28, in verify
    await sio.connect('http://localhost:8000')
  File "C:\Users\gatto\AppData\Roaming\Python\Python37\site-packages\socketio\asyncio_client.py", line 111, in connect
    engineio_path=socketio_path)
  File "C:\Users\gatto\AppData\Roaming\Python\Python37\site-packages\engineio\asyncio_client.py", line 87, in connect
    async_signal_handler)
  File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\lib\asyncio\events.py", line 540, in add_signal_handler
    raise NotImplementedError
NotImplementedError

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\lib\site-packages\discord\ext\commands\bot.py", line 903, in invoke
    await ctx.command.invoke(ctx)
  File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\lib\site-packages\discord\ext\commands\core.py", line 855, in invoke
    await injected(*ctx.args, **ctx.kwargs)
  File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\lib\site-packages\discord\ext\commands\core.py", line 94, in wrapped
    raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: NotImplementedError:

This is my code:

import socketio
import discord
from discord.ext import commands
import time
import asyncio


data = time.strftime("%d/%m/%Y")
ora = time.strftime("%H:%M:%S")
sio = socketio.AsyncClient(logger=True, engineio_logger=True)


@sio.event()
async def url_received(data):
    print(data)


class Sub(commands.Cog):

    def __init__(self, bot):
        self.bot = bot


    @commands.command()
    async def verify(self, ctx):
        if ctx.message.channel.id == 749357312048758805:
            embed = discord.Embed(title="TEST", description="**TEST DESCRIPTION!**", color=0x00ff00)
            embed.set_footer(text="TEST MESSAGE | {}".format(data))
            await sio.connect('http://127.0.0.1:5000/')
            await sio.emit("URL REQUEST")
            await ctx.send(embed=embed) 

What is the cause of this? If you need more information, please ask.
Thanks in advance.

bug

Most helpful comment

Hi, I got the same error. It helped me to get back to version python-engineio-3.13.1

All 9 comments

Looks like the async signal handler that caches Ctrl-C does not work on Windows. I'm going to need to find an alternative way to set this up on that OS.

Thanks for your interest. Approximately when do you think a solution might be available? In the meantime, I will be forced to move to Linux.

Hi, I got the same error. It helped me to get back to version python-engineio-3.13.1

Hi...is there any news or available work around? Rolling back to python-engineio-3.13.1 did not seem to fix the issue

@urishiraval master branch of https://github.com/miguelgrinberg/python-engineio project has a likely fix for this. Would you like to test it out and report?

@miguelgrinberg I can sure try, but I have to wait for my colleague's Windows pc to become available so it will take a while

@miguelgrinberg I just met with this issue and can confirm that the master branch works

@miguelgrinberg I can sure try, but I have to wait for my colleague's Windows pc to become available so it will take a while

Can also confirm that the master branch does indeed work. @miguelgrinberg

Was this page helpful?
0 / 5 - 0 ratings

Related issues

grjzwaan picture grjzwaan  路  3Comments

rstuckey picture rstuckey  路  4Comments

alcupe picture alcupe  路  5Comments

kamranhossain picture kamranhossain  路  7Comments

sraboncmc picture sraboncmc  路  5Comments