disclaimer; i'm not big on threading, however have some experience dealing with multiprocessing / distributing jobs over a grid.
> Multithreading is a really important because it could lead to: > - separate the modeling operations and display tasks, this could be easy, since displaying doesn't involve the data processed by another thread. > - assign a task per core on multicore machines, and then drastically > improve performances. in the case of a bool.op. the shape from which other shapes would be subtracted would be locked, and only available in the thread/proc working on it. when done, it would become available again. so, its quite likely that there will be no speed up whatsoever... > Because I don't like to remain in the darkness, I wrote a small sample that > uses the python 'threading' module as well as pythonOCC. Here is the > scenario: > - one thread creates a set of 10 points (gp_Pnt), > - a second thread create vertices from these points. > - exchanges between these threads use a Queue named QUEUE_POINTS. > > This sample was committed to the svn repository in a new > 'samples/Threading' folder, and the output from this script is pasted below. > It seems to work quite well, the question being now, from my point of view: > 'Can we find an example where multithreading is not possible? and why?' well, the example below is perhaps a little too easy; first because what makes threading hard is that it grants access to data simultaneous, which allows you to corrupt it if you don't properly lock it. this is what makes threading hard, managing data access, and keeping the data state in a proper state. lastly, because of the GIL ( global interpreter lock ) see: http://wiki.python.org/moin/GlobalInterpreterLock so, to make the script more meaningful, it would help to use the multiprocessing module, and use several processes. personally, i'm a huge fan of the multiprocessing module. its really close to the threading API and has great performance. its interesting to think of the role of threads/procs in the context of pyOCC. personally I think running the GUI in one process and running modelling operations in another ( or several ) is an interesting idea. multiprocessing is the way to go when channeling all the resources of your machine. Cheers, -jelle
_______________________________________________ Pythonocc-users mailing list Pythonocc-users@gna.org https://mail.gna.org/listinfo/pythonocc-users