Skip to content

Dynamic manager does not work with python3 concurrent futures package. #84

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
proofit404 opened this issue Nov 29, 2019 · 1 comment
Closed

Comments

@proofit404
Copy link

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})
@amcgregor
Copy link
Member

Correction applied in the cegid branch; these downstream changes will be merged "Real Soon Now™", but are available for use if required.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants