Files
flatcam-wsl/appPool.py
Marius Stanciu 33de5314b1 - in Tool Milling made sure that deleting the only tool will not crash the application
- added a new parameter in Preferences to control the number of processes created by the Pool() - more processes better performance but also a lot of memory consumed
- made sure that the display of messages in the Status Bar is done asap
2023-03-01 18:15:10 +02:00

33 lines
765 B
Python

from PyQt6 import QtCore
from multiprocessing import Pool, cpu_count
import dill
def run_dill_encoded(what):
fun, args = dill.loads(what)
print("load", fun, args)
return fun(*args)
def apply_async(pool, fun, args):
print("...", fun, args)
print("dumps", dill.dumps((fun, args)))
return pool.map_async(run_dill_encoded, (dill.dumps((fun, args)),))
def func1():
print("func")
class WorkerPool(QtCore.QObject):
def __init__(self):
super(WorkerPool, self).__init__()
self.pool = Pool(int(cpu_count() / 4))
def add_task(self, task):
print("adding task", task)
# task['fcn'](*task['params'])
# print self.pool.map(task['fcn'], task['params'])
apply_async(self.pool, func1, ())