Use an RLock in the completion worker, just in case

This commit is contained in:
Kovid Goyal 2017-06-16 08:34:19 +05:30
parent 496e98b7ae
commit 51c4ee2343
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -7,7 +7,7 @@ __license__ = 'GPL v3'
__copyright__ = '2014, Kovid Goyal <kovid at kovidgoyal.net>'
import cPickle, os, sys
from threading import Thread, Event, Lock
from threading import Thread, Event, RLock
from Queue import Queue
from contextlib import closing
from collections import namedtuple
@ -37,7 +37,7 @@ class CompletionWorker(Thread):
self.current_completion_request = None
self.latest_completion_request_id = None
self.request_count = 0
self.lock = Lock()
self.lock = RLock()
def launch_worker_process(self):
from calibre.utils.ipc.server import create_listener
@ -159,6 +159,7 @@ class CompletionWorker(Thread):
self.worker_process.kill()
return self.worker_process.returncode
_completion_worker = None
@ -175,6 +176,7 @@ def run_main(func):
with closing(Client(address, authkey=key)) as control_conn, closing(Client(address, authkey=key)) as data_conn:
func(control_conn, data_conn)
Result = namedtuple('Result', 'request_id ans traceback query')