python-osc
python-osc copied to clipboard
Running out of Threads with Lidar data
I hoped the python-osc could cope with data being sent to it. I am having problems as the python app freezes very quickly with the error insufficient threads, my code is in https://github.com/jtreg/forgiveness_machine . please can someone advise?
The Forgiveness Machine looks amazing. It looks like several of the functions you call are running for DEFAULT_RUNNING_TIME (2 seconds). If the rate of incoming OSC messages is greater than one every 2 seconds, threads will pile up. Maybe you could have each actuator running on its own thread and have your osc handler route messages to a queue for that thread or something.
@jsheedy recommendation seems reasonable, although you should also be able to tune your lidar data to only need just a few bytes sent from time to time if it's just for detecting the presence of someone. If you want to stick with OSC and threads you can look at decreasing the stack size with ulimit to potentially increase the number of threads you can run (not a super elegant solution, just writing this down as a possibility...), or you can try to go with a ForkingOSCUDPServer instead of the ThreadingOSCUDPServer that you're using now, might be heavyweight for the raspberry pi you're running on but if your operations are also heavy weight that might work out better than threads. hope that helps!