From ac2fc9c2a0e0d3eb32fd1c7f644eebe416e27597 Mon Sep 17 00:00:00 2001 From: "James R. Barlow" Date: Sun, 19 May 2019 15:06:47 -0700 Subject: [PATCH] Explain picklable logger --- src/ocrmypdf/_jobcontext.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/ocrmypdf/_jobcontext.py b/src/ocrmypdf/_jobcontext.py index cc23de85..5daab103 100644 --- a/src/ocrmypdf/_jobcontext.py +++ b/src/ocrmypdf/_jobcontext.py @@ -33,10 +33,11 @@ class PicklableLoggerMixin: return self._log def __getstate__(self): - log = self._log - self._log = None - state = self.__dict__ - self._log = log + # Python 3.6 is incapable of pickling a logger and marshalling it to another + # process (threading._RLock error), so we disconnect it before pickling, + # and create a new logger in the worker process. + state = self.__dict__.copy() + state['_log'] = None return state