If this is truly independent of any workbench, then you could perhaps place it in src/3rdParty/, just like lazy_loader, which is a small class taken from the TensorFlow project.
Python Multithreaded with MULTICORE [Solved]
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Be nice to others! Respect the FreeCAD code of conduct!
Re: Python Multithreaded with MULTICORE [Solved]
Always add the important information to your posts if you need help. Also see Tutorials and Video tutorials.
To support the documentation effort, and code development, your donation is appreciated: liberapay.com/FreeCAD.
To support the documentation effort, and code development, your donation is appreciated: liberapay.com/FreeCAD.
Re: Python Multithreaded with MULTICORE [Solved]
It is independent. The only thing to change is the first code line
Code: Select all
from freecad.marz.extension import App, QtCore
Code: Select all
import FreeCAD as App
from PySide import QtCore
Re: Python Multithreaded with MULTICORE [Solved]
Well, I haven't used it. I would at least try it if it was already in the source, but otherwise we can wait for etrombly's feedback.
Truth is development in FreeCAD is perhaps wilder than you may expect; we add things without thinking too much about them because it's better to keep dynamic development going on. If it turns out it wasn't a good idea, we can remake or undo the changes, that's pretty much how we've gotten to this point (which is maybe a bit messy, but hey it's dynamic).
Always add the important information to your posts if you need help. Also see Tutorials and Video tutorials.
To support the documentation effort, and code development, your donation is appreciated: liberapay.com/FreeCAD.
To support the documentation effort, and code development, your donation is appreciated: liberapay.com/FreeCAD.
Re: Python Multithreaded with MULTICORE [Solved]
I'll let you know once I've tested a little more. The only thing I changed so far is adding an isDone() method that just returns self._isTerminated so you don't have to block like in get().mnesarco wrote: ↑Sat Jul 18, 2020 3:12 am If you really think it is ready for general use, I can send the PR, but it could be advisable to wait some comments from people that use it in their own projects, I wrote it to solve a specific problem in MarzWorkbench and it works very well in that context. But I have no feedback from other devs/contexts.
Re: Python Multithreaded with MULTICORE [Solved]
Thank you for your feedback.
Yes that version is pretty simplified and contains only needed things used in MarzWorkbench, I have started a more generic and complete version with support for signals/slots to monitor the threads but it is used in another internal project. I will explore the possibility to publish that version.
Re: Python Multithreaded with MULTICORE [Solved]
BTW, there is also a useful Worker implementation in ExtMan and it is 100% standalone also:
https://github.com/mnesarco/FreeCAD_Ext ... /worker.py
Usage
https://github.com/mnesarco/FreeCAD_Ext ... /worker.py
Usage
Code: Select all
# Define your task function
def mytask(...):
....
return something
# If you want to be notified async, define a listener
def mylistener( data ):
result, error, target = data
....
# Create a job with your task
job = Worker(mytask, ...)
# get result async [optional]
job.signals.finished.connect( mylistener )
# Start the job in another thread
job.start()
# get result blocking [optional]
result = job.get()