Simplified code:

---%<------------------------------------------
class Foo:
    tasks = []
    def process(self, *args):
        # process with the file
        # save result on disk with a new name
        self.out_filename.write(.....)

    def run_multitasks(self):
        while self.tasks:
            t = Thread(target=process, args=self.tasks.pop(0))
            t.start()
            t.join()
            self.callback(self.out_filename)

    def add_task(self, fname, callback):
        self.tasks.append(fname)
        self.callback = callback
        if len(self.tasks) == 1:
            self.run_multitasks()

def slot(filename):
    print(filename)                 # Works
    print("%s created" % filename)  # Segfault !

Files = [list of files]
foo = Foo()
for f in Files:
    foo.add_task(f, slot)
---%<------------------------------------------

If I place self.callback() at the end of the func process that doesn't change anything.


Regards,

Vincent.

--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to