View Single Post
Old 08-10-2021, 10:12 PM   #1
xxyzz
Evangelist
xxyzz ought to be getting tired of karma fortunes by now.xxyzz ought to be getting tired of karma fortunes by now.xxyzz ought to be getting tired of karma fortunes by now.xxyzz ought to be getting tired of karma fortunes by now.xxyzz ought to be getting tired of karma fortunes by now.xxyzz ought to be getting tired of karma fortunes by now.xxyzz ought to be getting tired of karma fortunes by now.xxyzz ought to be getting tired of karma fortunes by now.xxyzz ought to be getting tired of karma fortunes by now.xxyzz ought to be getting tired of karma fortunes by now.xxyzz ought to be getting tired of karma fortunes by now.
 
Posts: 442
Karma: 2666666
Join Date: Nov 2020
Device: none
Terminate process in ThreadedJob terminates calibre main process

I was using spaCy's multiprocessing pipe(https://github.com/explosion/spaCy/b...guage.py#L1581) in ThreadedJob but found it will terminate calibre, I think the code should looks like this:

Code:
from multiprocessing import Process
from threading import Thread

def fun():
    while True:
        pass

class JobThread(Thread):
    def run(self):
        # code in ThreadedJob
        p = Process(target=fun)
        p.start()
        p.terminate()

JobThread().start()  # pretend it's ThreadedJobServer
The process created in ThreadedJob is still running but the calibre main process is terminated.

I also want to know the difference between calibre's ParallelJob and ThreadedJob.
xxyzz is offline   Reply With Quote