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

flush-queue fails if unprintable char in args #30

Open
tcarlander opened this issue Mar 21, 2019 · 3 comments
Open

flush-queue fails if unprintable char in args #30

tcarlander opened this issue Mar 21, 2019 · 3 comments

Comments

@tcarlander
Copy link
Collaborator

if the args contain some non ascii chars sometimes flush-queue stops with:

  File "/....../lib/python3.4/site-packages/async/management/commands/flush_queue.py", line 63, in run
    print ("%s: %s" % (job.id, job))
UnicodeEncodeError: 'ascii' codec can't encode character '\xe9' in position 137: ordinal not in range(128)

the args in the above failure where:
["fiche-de-suivi-mensuel-collines", "ben", {"query": "l\u00e9a", "group": null, "status": null}, {"host": "ben.mdca.wfp.org", "is_secure": false}, false, false]

the job finished but was never marked completed as it broke on print job

@KayEss
Copy link
Member

KayEss commented Mar 22, 2019

Python and Unicode. Gotta love it! This is Python 3? I thought that was supposed to fix Python's terrible Unicode support. 👎 For 2 I would suggest trying

print (u"%s: %s" % (job.id, job))

But I don't know what the right thing for 3 is....

@tcarlander
Copy link
Collaborator Author

tcarlander commented Mar 22, 2019

It is for python 3.
I have looked more in to it and realise that the issue is in the unicode() of the job
somewhere here:

class Job(models.Model):
.
.
.
.
    def __unicode__(self):
        # __unicode__: Instance of 'bool' has no 'items' member
        # pylint: disable=E1103
        arglist = simplejson.loads(self.args)
        arglist = [repr(s) for s in arglist]
        kwargs = simplejson.loads(self.kwargs)
        kwargs = sorted([u"%s=%s" % (k, repr(v)) for k, v in kwargs.items()])
        args = u', '.join(arglist + kwargs)

it occurs when doing the print of the job

@KayEss
Copy link
Member

KayEss commented Mar 22, 2019

Hmm, if I had to point fingers I think it'd be at the repr(s) in the arglist, although all of the strings there are marked Unicode.

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

No branches or pull requests

2 participants