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:
- Firstly, and most of you using the Python bot probably know this, the
signalrcoreis 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.
- Secondly, now that the state updates are getting a lot bigger (due to territory nodes, available nodes etc) the
websockets-clientthat 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-clientlibrary 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!