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