Possible solution to slow Python bot response times

Hey everyone, I too have been plagued with the slow Python bot response times (Python and Signal response time issues) , but I think I’ve found a solution and I’d thought share them to spare others from the tears it caused me:

  1. Firstly, and most of you using the Python bot probably know this, the signalrcore is synchronous. This means that you should keep your event handler functions short-running, because the next receive/send event is not going to go through until the previous one is done. I’d recommend putting all your heavy-lifting logic in your main thread and using the event handler functions only to push data to a processing queue.
  2. Secondly, now that the state updates are getting a lot bigger (due to territory nodes, available nodes etc) the signalrcore library (and websockets-client that it uses under the hood) starts choking up, leading to ticks getting delayed several seconds and then rapidly firing one after the other, Luckily, this can be resolved by installing wsaccel (wsaccel · PyPI) - I found this handy tip in the websockets-client library readme here: https://github.com/websocket-client/websocket-client#performance. Once I installed that my bot was finally able to keep up with the ticks as they are coming through.

Hope this helps someone else - good luck with the last stretch before Saturday!


Too little time lol, loadshedding is really killing it especially with coding on a pc.
Hopefully we get an extension otherwise might have to try and output some bot for the finals.