0

I want make apply_async task with celery, but my argument is a file with encoding in ISO-8859-1, but celery serializer data with UTF-8.

I recive the file from one url using this code:

    import urllib

    data = urllib.request.urlopen(url)
    content = data.read()
    update_task.apply_async([content])

When I try call the method I have this erro:

UnicodeDecodeError: 'utf-8' codec can't decode byte

Lucas Resende
  • 582
  • 5
  • 14

1 Answers1

1

You should decode url response like content.decode('ISO-8859-1') before passing it to apply_async. Or pass just url to celery queue and make request to this url in task function

For more info about decoding urlopen response read this post

Alex C
  • 411
  • 3
  • 6