multithreading - Autodesk's Fbx Python and threading -


i'm trying use fbx python module autodesk, seems can't thread operation. seems due gil not relased. has found same issue or doing wrong? when doesn't work, mean code doesn't release thread , i'm not able else, while fbx code running.

there isn't of code post, know whether did happen try.

update:

here example code, please note each fbx file 2gb

import os import fbx import threading  file_dir = r'../fbxfiles'   def parse_fbx(filepath):     print '-' * (len(filepath) + 9)     print 'parsing:', filepath      manager = fbx.fbxmanager.create()     importer = fbx.fbximporter.create(manager, '')     status = importer.initialize(filepath)     if not status:         raise ioerror()      scene = fbx.fbxscene.create(manager, '')     importer.import(scene)     # freeup memory     rootnode = scene.getrootnode()      def traverse(node):         print node.getname()          in range(0, node.getchildcount()):             child = node.getchild(i)             traverse(child)      # run     traverse(rootnode)     importer.destroy()     manager.destroy()   files = os.listdir(file_dir) tt = []  file_ in files:     filepath = os.path.join(file_dir, file_)     t = threading.thread(target=parse_fbx, args=(filepath,))     tt.append(t)     t.start() 

one problem see traverse() function. it's calling recursively potentially huge number of times. having threads printing stuff @ same time. doing requires coordinating access shared output device (i.e. screen). simple way creating , using global threading.lock object.

first create global lock prevent threads printing @ same time:

file_dir = '../fbxfiles'  # "r" prefix needed when path contains backslashes print_lock = threading.lock()  # add here 

then make non-recursive version of traverse() uses it:

    def traverse(rootnode):         print_lock:             print rootnode.getname()          in range(node.getchildcount()):             child = node.getchild(i)             print_lock:                 print child.getname() 

it's not clear me reading of each fbxfile takes place. if happens result of importer.import(scene) call, time other threads given chance run — unless i/o [also] done within traverse() function.

since printing form of output, thread switching able occur when it's done. however, if function did perform computations of kind, no multi-threading take place within during execution.

once multi-reading working, may encounter insufficient memory issues if multiple 2gb fbxfiles being read memory simultaneously various different threads.


Comments

Popular posts from this blog

account - Script error login visual studio DefaultLogin_PCore.js -

xcode - CocoaPod Storyboard error: -