python-bonobo / bonobo

Extract Transform Load for Python 3.5+
https://www.bonobo-project.org/
Apache License 2.0
1.59k stars 146 forks source link

django with celery raise an exception on LoggingProxy #352

Open nahuelange opened 5 years ago

nahuelange commented 5 years ago

When I run through a celery task a call_command, an exception is raised with this stacktrace:

celery_1          |     call_command('my_etl_command', )
celery_1          |   File "/code/venv/lib/python3.6/site-packages/django/core/management/__init__.py", line 110, in call_command
celery_1          |     command = load_command_class(app_name, command_name)
celery_1          |   File "/code/venv/lib/python3.6/site-packages/django/core/management/__init__.py", line 36, in load_command_class
celery_1          |     module = import_module('%s.management.commands.%s' % (app_name, name))
celery_1          |   File "/usr/lib/python3.6/importlib/__init__.py", line 126, in import_module
celery_1          |     return _bootstrap._gcd_import(name[level:], package, level)
celery_1          |   File "<frozen importlib._bootstrap>", line 994, in _gcd_import
celery_1          |   File "<frozen importlib._bootstrap>", line 971, in _find_and_load
celery_1          |   File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
celery_1          |   File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
celery_1          |   File "<frozen importlib._bootstrap_external>", line 678, in exec_module
celery_1          |   File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
celery_1          |   File "/code/src/custom/dataloader/management/commands/etl_features_to_es.py", line 1, in <module>
celery_1          |     import bonobo
celery_1          |   File "/code/venv/lib/python3.6/site-packages/bonobo/__init__.py", line 10, in <module>
celery_1          |     from bonobo._api import *
celery_1          |   File "/code/venv/lib/python3.6/site-packages/bonobo/_api.py", line 10, in <module>
celery_1          |     from bonobo.execution.strategies import create_strategy
celery_1          |   File "/code/venv/lib/python3.6/site-packages/bonobo/execution/strategies/__init__.py", line 9, in <module>
celery_1          |     from bonobo.execution.strategies.executor import ProcessPoolExecutorStrategy, ThreadPoolExecutorStrategy
celery_1          |   File "/code/venv/lib/python3.6/site-packages/bonobo/execution/strategies/executor.py", line 7, in <module>
celery_1          |     from bonobo.execution.strategies.base import Strategy
celery_1          |   File "/code/venv/lib/python3.6/site-packages/bonobo/execution/strategies/base.py", line 1, in <module>
celery_1          |     from bonobo.execution.contexts.graph import GraphExecutionContext
celery_1          |   File "/code/venv/lib/python3.6/site-packages/bonobo/execution/contexts/__init__.py", line 8, in <module>
celery_1          |     from bonobo.execution.contexts.graph import GraphExecutionContext
celery_1          |   File "/code/venv/lib/python3.6/site-packages/bonobo/execution/contexts/graph.py", line 9, in <module>
celery_1          |     from bonobo.execution.contexts.node import NodeExecutionContext
celery_1          |   File "/code/venv/lib/python3.6/site-packages/bonobo/execution/contexts/node.py", line 12, in <module>
celery_1          |     from bonobo.execution.contexts.base import BaseContext
celery_1          |   File "/code/venv/lib/python3.6/site-packages/bonobo/execution/contexts/base.py", line 6, in <module>
celery_1          |     from mondrian import term
celery_1          |   File "/code/venv/lib/python3.6/site-packages/mondrian/__init__.py", line 23, in <module>
celery_1          |     if sys.stdout.encoding is None or sys.stdout.encoding == "ANSI_X3.4-1968":
celery_1          | AttributeError: 'LoggingProxy' object has no attribute 'encoding'

Versions

bonobo==0.6.4

CPython 3.6.8 (default, Jan 14 2019, 11:02:34) [GCC 8.0.1 20180414 (experimental) [trunk revision 259383]]

Linux 49788264f88a 5.0.0-15-generic #16-Ubuntu SMP Mon May 6 17:41:33 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux

Distributor ID: Ubuntu Description: Ubuntu 18.04.1 LTS Release: 18.04 Codename: bionic

...
nahuelange commented 5 years ago

This could be a related issue https://github.com/celery/celery/issues/928

jrmi commented 4 years ago

fixed by https://github.com/Terralego/visu-back/pull/37

jrmi commented 3 years ago

A fix is in progress on mondrian: https://github.com/python-mondrian/mondrian/pull/18