Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting error when debugging but not when running my program #473

Open
manuelarte opened this issue Nov 15, 2024 · 1 comment
Open

Getting error when debugging but not when running my program #473

manuelarte opened this issue Nov 15, 2024 · 1 comment

Comments

@manuelarte
Copy link

So I have the following program:

# __main__.py
import os

from mybot.bot import MyBot
from dotenv import load_dotenv

if __name__ == '__main__':
    load_dotenv()

    access_token = os.getenv('ACCESS_TOKEN')
    assert access_token is not None, "ACCESS_TOKEN env variable not set"
    bot = MyBot(access_token)
    bot.run()
# bot.py
from twitchio.ext import commands


class MyBot(commands.Bot):

    def __init__(self, access_token: str):
        # Initialise our Bot with our access token, prefix and a list of channels to join on boot...
        super().__init__(token=access_token, prefix='!', initial_channels=['...'])

    async def event_ready(self):
        # We are logged in and ready to chat and use commands...
        print(f'Logged in as | {self.nick}')
        print(f'User id is | {self.user_id}')

    @commands.command()
    async def hello(self, ctx: commands.Context):
        # Send a hello back!
        await ctx.send(f'Hello {ctx.author.name}!')

When I run the program everything works fine, but when I try to debug my program I get:

Exception ignored in: <function Task.__del__ at 0x0000029BE865B420>
Traceback (most recent call last):
  File "C:\Users\Manuel\AppData\Local\Programs\Python\Python312\Lib\asyncio\tasks.py", line 150, in __del__
    self._loop.call_exception_handler(context)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'call_exception_handler'
Traceback (most recent call last):
  File "C:\Users\Manuel\PycharmProjects\eft-troll\.venv\Lib\site-packages\twitchio\client.py", line 159, in run
    self.loop.run_until_complete(task)  # this'll raise if the connect fails
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Program Files\JetBrains\PyCharm 2024.1.4\plugins\python\helpers-pro\pydevd_asyncio\pydevd_nest_asyncio.py", line 243, in run_until_complete
    return f.result()
           ^^^^^^^^^^
  File "C:\Users\Manuel\AppData\Local\Programs\Python\Python312\Lib\asyncio\futures.py", line 203, in result
    raise self._exception.with_traceback(self._exception_tb)
  File "C:\Users\Manuel\AppData\Local\Programs\Python\Python312\Lib\asyncio\tasks.py", line 314, in __step_run_and_handle_result
    result = coro.send(None)
             ^^^^^^^^^^^^^^^
  File "C:\Users\Manuel\PycharmProjects\eft-troll\.venv\Lib\site-packages\twitchio\client.py", line 192, in connect
    await self._connection._connect()
  File "C:\Users\Manuel\PycharmProjects\eft-troll\.venv\Lib\site-packages\twitchio\websocket.py", line 140, in _connect
    data = await self._client._http.validate(token=self._token)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Manuel\PycharmProjects\eft-troll\.venv\Lib\site-packages\twitchio\http.py", line 298, in validate
    async with self.session.get(url, headers=headers) as resp:
  File "C:\Users\Manuel\PycharmProjects\eft-troll\.venv\Lib\site-packages\aiohttp\client.py", line 1418, in __aenter__
    self._resp: _RetType = await self._coro
                           ^^^^^^^^^^^^^^^^
  File "C:\Users\Manuel\PycharmProjects\eft-troll\.venv\Lib\site-packages\aiohttp\client.py", line 696, in _request
    conn = await self._connector.connect(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Manuel\PycharmProjects\eft-troll\.venv\Lib\site-packages\aiohttp\connector.py", line 544, in connect
    proto = await self._create_connection(req, traces, timeout)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Manuel\PycharmProjects\eft-troll\.venv\Lib\site-packages\aiohttp\connector.py", line 1050, in _create_connection
    _, proto = await self._create_direct_connection(req, traces, timeout)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Manuel\PycharmProjects\eft-troll\.venv\Lib\site-packages\aiohttp\connector.py", line 1345, in _create_direct_connection
    hosts = await self._resolve_host(host, port, traces=traces)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Manuel\PycharmProjects\eft-troll\.venv\Lib\site-packages\aiohttp\connector.py", line 980, in _resolve_host
    resolved_host_task = asyncio.Task(coro, loop=loop, eager_start=True)
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: _patch_task.<locals>.task_new_init() got an unexpected keyword argument 'eager_start'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Program Files\JetBrains\PyCharm 2024.1.4\plugins\python\helpers\pydev\pydevd.py", line 1551, in _exec
    pydev_imports.execfile(file, globals, locals)  # execute the script
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Program Files\JetBrains\PyCharm 2024.1.4\plugins\python\helpers\pydev\_pydev_imps\_pydev_execfile.py", line 18, in execfile
    exec(compile(contents+"\n", file, 'exec'), glob, loc)
  File "C:\Users\Manuel\PycharmProjects\eft-troll\eft_troll\__main__.py", line 12, in <module>
    bot.run()
  File "C:\Users\Manuel\PycharmProjects\mybot\.venv\Lib\site-packages\twitchio\client.py", line 165, in run
    self.loop.run_until_complete(self.close())
  File "C:\Program Files\JetBrains\PyCharm 2024.1.4\plugins\python\helpers-pro\pydevd_asyncio\pydevd_nest_asyncio.py", line 243, in run_until_complete
    return f.result()
           ^^^^^^^^^^
  File "C:\Users\Manuel\AppData\Local\Programs\Python\Python312\Lib\asyncio\futures.py", line 203, in result
    raise self._exception.with_traceback(self._exception_tb)
  File "C:\Users\Manuel\AppData\Local\Programs\Python\Python312\Lib\asyncio\tasks.py", line 314, in __step_run_and_handle_result
    result = coro.send(None)
             ^^^^^^^^^^^^^^^
  File "C:\Users\Manuel\PycharmProjects\mybot\.venv\Lib\site-packages\twitchio\client.py", line 200, in close
    await self._connection._close()
  File "C:\Users\Manuel\PycharmProjects\mybot\.venv\Lib\site-packages\twitchio\websocket.py", line 595, in _close
    self._keeper.cancel()
    ^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'cancel'
python-BaseException
Unclosed client session
client_session: <aiohttp.client.ClientSession object at 0x0000029BE8F97CB0>
sys:1: RuntimeWarning: coroutine 'TCPConnector._resolve_host_with_throttle' was never awaited

any idea why?

Copy link

Hello! Thanks for the issue. If this is a general help question, for a faster response consider joining the official Discord Server

Else if you have an issue with the library please wait for someone to help you here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant