Skip to content
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

UnicodeEncodeError when using send_task() with message containing german umlauts #117

Open
fgmehlin opened this issue Apr 3, 2018 · 2 comments

Comments

@fgmehlin
Copy link

fgmehlin commented Apr 3, 2018

It seems sending a task with german umlauts triggers a :
UnicodeEncodeError: 'ascii' codec can't encode character '\xe4' in position xx: ordinal not in range(128)

Working example :

# Note the 'o', replacing 'note'
extract_tasks = [(arg1, note_id, 'o') for note_id, note in
                         enumerate(some_dict[arg1])]

results = [extractor_app.send_task('extractor.app.extract', x,
                queue='extractor', exchange='extractor',
                key='extractor') for x in extract_tasks]

Failing example :

# Note the 'ö', replacing 'note'
extract_tasks = [(arg1, note_id, 'ö') for note_id, note in
                         enumerate(some_dict[arg1])]

results = [extractor_app.send_task('extractor.app.extract', x,
                queue='extractor', exchange='extractor',
                key='extractor') for x in extract_tasks]

triggers :

Traceback (most recent call last):
  File "/usr/local/lib/python3.6/multiprocessing/process.py", line 258, in _bootstrap
    self.run()
  File "/usr/local/lib/python3.6/multiprocessing/process.py", line 93, in run
    self._target(*self._args, **self._kwargs)
  File "/usr/src/app/patient_processing/patient_process_orchestrator.py", line 67, in preprocess_patient
    patient_concepts_dict = self._pool_extract(extract_tasks)
  File "/usr/src/app/patient_processing/patient_process_orchestrator.py", line 236, in _pool_extract
    key='extractor') for x in extract_tasks]
  File "/usr/src/app/patient_processing/patient_process_orchestrator.py", line 236, in <listcomp>
    key='extractor') for x in extract_tasks]
  File "/usr/local/lib/python3.6/site-packages/celery/app/base.py", line 737, in send_task
    amqp.send_task_message(P, name, message, **options)
  File "/usr/local/lib/python3.6/site-packages/celery/app/amqp.py", line 554, in send_task_message
    **properties
  File "/usr/local/lib/python3.6/site-packages/kombu/messaging.py", line 181, in publish
    exchange_name, declare,
  File "/usr/local/lib/python3.6/site-packages/kombu/connection.py", line 494, in _ensured
    return fun(*args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/kombu/messaging.py", line 203, in _publish
    mandatory=mandatory, immediate=immediate,
  File "/usr/local/lib/python3.6/site-packages/librabbitmq-2.0.0-py3.6-linux-x86_64.egg/librabbitmq/__init__.py", line 122, in basic_publish
    mandatory or False, immediate or False,
UnicodeEncodeError: 'ascii' codec can't encode character '\xe4' in position 155: ordinal not in range(128)

Using python3 and
librabbitmq==2.0.0
celery==4.1.0

@auvipy auvipy closed this as completed Apr 3, 2018
@auvipy auvipy reopened this Apr 3, 2018
@fgmehlin fgmehlin changed the title Issue when using send_task() with message containing german umlauts UnicodeEncodeError when using send_task() with message containing german umlauts Apr 3, 2018
@auvipy
Copy link
Member

auvipy commented Apr 3, 2018

pyamqp is the recommended package. try that to see the issue is gone

@fgmehlin
Copy link
Author

fgmehlin commented Apr 3, 2018

@auvipy pyamqp indeed solved the issue. Thanks for the quick answer!

Cheers !

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