Return str to a callback raise a segfault if used in string formating
Vincent Vande Vyvre
vincent.vande.vyvre at telenet.be
Fri Oct 13 01:46:06 EDT 2017
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.
More information about the Python-list
mailing list