mailer icon indicating copy to clipboard operation
mailer copied to clipboard

Dynamic manager does not work with python3 concurrent futures package.

Open proofit404 opened this issue 5 years ago • 0 comments

Exception

Traceback (most recent call last):
  File "django/core/handlers/exception.py", line 41, in inner
    response = get_response(request)
  File "django/core/handlers/base.py", line 187, in _get_response
    response = self.process_exception_by_middleware(e, request)
  File "django/core/handlers/base.py", line 185, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "contextlib.py", line 74, in inner
    return func(*args, **kwds)
  File "django/views/decorators/csrf.py", line 58, in wrapped_view
    return view_func(*args, **kwargs)
  File "rest_framework/viewsets.py", line 114, in view
    return self.dispatch(request, *args, **kwargs)
  File "rest_framework/views.py", line 505, in dispatch
    response = self.handle_exception(exc)
  File "rest_framework/views.py", line 465, in handle_exception
    self.raise_uncaught_exception(exc)
  File "rest_framework/views.py", line 476, in raise_uncaught_exception
    raise exc
  File "rest_framework/views.py", line 502, in dispatch
    response = handler(request, *args, **kwargs)
  File "marrow/mailer/__init__.py", line 149, in send
    result = self.manager.deliver(message)
  File "marrow/mailer/manager/dynamic.py", line 177, in deliver
    return self.executor.submit(partial(worker, self.transport), message)
  File "concurrent/futures/thread.py", line 147, in submit
    if self._broken:
AttributeError: 'ScalingPoolExecutor' object has no attribute '_broken'

Workaround

from concurrent.futures import ThreadPoolExecutor
from marrow.mailer.manager.dynamic import DynamicManager, ScalingPoolExecutor

class ScalingPoolExecutorHotFix(ScalingPoolExecutor):
    def __init__(self, workers, divisor, timeout):
        super().__init__(workers, divisor, timeout)
        ThreadPoolExecutor.__init__(self)

class DynamicManagerHotFix(DynamicManager):
    Executor = ScalingPoolExecutorHotFix

Mailer({'manager.use': DynamicManagerHotFix})

proofit404 avatar Nov 29 '19 13:11 proofit404