Python Multi threading

Hello everyone,

I was coding a simulation in Blender using bpy. Everything seemed to run perfectly until I introduced Multi_Threading. The UI is getting freezed when i run the code fragment. and error it says
AttributeError: ‘NoneType’ object has no attribute ‘objects’ for line bpy.data.objects

def process_data(threadName, q, frameNumber)-> int:
while not exitFlag:
queueLock.acquire()
if not workQueue.empty():
data = q.get()
frameNumber = runWarehouse(threadName, data, frameNumber)
queueLock.release()
print ("%s processing %s" % (threadName, data))
else:
queueLock.release()
time.sleep(1)

def runWarehouse(nameRobot, nameReck, frameNumber) -> int:
objRobot = bpy.data.objects[nameRobot]
objReck = bpy.data.objects[nameReck]
{Some code running from here}

I am totally new to Blender programming. Not sure if threading support is available for blender
If anyone can help on this will be welcome Thanks in advance

I’m too lazy to wade through your unformatted code but…

Python threading is a bit peculiar due to the presence of something called the Global Interpreter Lock (GIL). Long story short, this means you can have multiple threads, but only one is running at a given time. This is a bit different from typical threading models.

The Python guys recommend using multi-processing instead of threading is you really, really, need concurrency.

Please see:
https://docs.blender.org/api/current/info_gotcha.html#strange-errors-when-using-the-threading-module

1 Like