0

I'm adding Discord capabilities to an existing python multithreaded program which is running inside Docker, but I keep getting the same error in the logs:

[2022-03-09 17:58:45,133][WARNING] Shard ID None heartbeat blocked for more than 10 seconds.
Loop thread traceback (most recent call last):
  File "/root/bagley/bagley.py", line 51, in <module>
    lib.bot.initBot(controller)
  File "/root/bagley/lib/bot.py", line 106, in initBot
    bot.run(config.DISCORD_TOKEN)
  File "/usr/local/lib/python3.8/dist-packages/discord/client.py", line 713, in run
    loop.run_forever()
  File "/usr/lib/python3.8/asyncio/base_events.py", line 570, in run_forever
    self._run_once()
  File "/usr/lib/python3.8/asyncio/base_events.py", line 1859, in _run_once
    handle._run()
  File "/usr/lib/python3.8/asyncio/events.py", line 81, in _run
    self._context.run(self._callback, *self._args)
  File "/usr/local/lib/python3.8/dist-packages/discord/client.py", line 702, in runner
    await self.start(*args, **kwargs)
  File "/usr/local/lib/python3.8/dist-packages/discord/client.py", line 666, in start
    await self.connect(reconnect=reconnect)
  File "/usr/local/lib/python3.8/dist-packages/discord/client.py", line 566, in connect
    await self.ws.poll_event()
  File "/usr/local/lib/python3.8/dist-packages/discord/gateway.py", line 559, in poll_event
    await self.received_message(msg.data)
  File "/usr/local/lib/python3.8/dist-packages/discord/gateway.py", line 427, in received_message
    msg = self._zlib.decompress(self._buffer)

I have already read another question in here where this same issue is discussed, however, I'm 100% sure that the code that the bot is running doesn't have any blocking functions and the Exception message seems to be related to internal functions from discord.py. I think that the problem is that my computer is not able to fully run the docker container with this big program so it sometimes gets blocked and it's unable to send and receive this heartbeat, but I really don't know what is happening.

Thanks a lot.

Edit:

I didn't mention that if I run the program out of Docker, there is no problem, however, the idea is to be able to deploy the program easily in a VPS, so not using Docker is not an option.

  • It in other words means that something in your code does not match the format of the rest of the code/is coded in a wrong way. Did you make sure that your code is written asynchronous and that you do not use outdated functions/code? – Dominik Mar 09 '22 at 18:53
  • From a high level perspective, the way the whole program works is that there are some threads that run synchronously and a controller which can modify their behaviour. The bot only communicates with the controller so that every command starts/stops the threads or modify a variable, etc. So in theory, there is only asynch code in the bot. – hacefresko Mar 09 '22 at 23:03

0 Answers0