Description
Hi,
This issue might be related or not to issue #43.
In my new Blender add-on project, I implemented an automatic retry function for the OSC server that fires every 500ms. It's quite handy for the user.
Lately I observed Blender taking all of my CPUs and, after investigation, it happens when the server is not able to connect (due to wrong settings) for a long time and therefore is still trying to connect again and again. I can reproduce the problem, the CPU usage rises very slowly and steadily until the app becomes unresponsive. It doesn't happen when the add-on connects successfully at the beginning and keeps the connection running, that's why I only discover the problem now.
If after all the failed attempts the server can at least connects it doesn't solve the issue, the CPU usage stays high and the only solution is to close Blender.
Here is an extract of my code:
def retry_server():
global osc_server, osc_in_ok
bcw = bpy.context.window_manager
ip = bcw.mom_osc_udp_in
port = bcw.mom_osc_port_in
if bcw.mom_osc_in_enable is True and osc_in_ok is False:
# try closing a previous instance
if osc_server is not None:
osc_server.stop_all()
osc_server = None
time.sleep(.01)
# try opening
try:
osc_server = OSCThreadServer(default_handler=OSC_callback)
osc_server.listen(address=ip, port=port, default=True)
bcw.mom_osc_alert = False
osc_in_ok = True
except:
bcw.mom_osc_alert = True
osc_server = None
if bcw.mom_osc_in_enable is False and osc_in_ok is True:
# try closing a previous instance
if osc_server is not None:
osc_server.stop_all()
osc_server = None
return .5
As you see I tried to clean the reference "osc_server", setting it to "None", but it doesn't solve the issue.
This is with python 3.7.0 under Ubuntu 18.04 LTS and a fresh "oscpy" copy from github.
Activity