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

TypeError: the JSON object must be str, not 'bytes' #13

Open
JendaPlhak opened this issue Apr 17, 2016 · 4 comments
Open

TypeError: the JSON object must be str, not 'bytes' #13

JendaPlhak opened this issue Apr 17, 2016 · 4 comments
Labels

Comments

@JendaPlhak
Copy link

JendaPlhak commented Apr 17, 2016

Hi,
running following code:

import retask

q = retask.Queue("myQueue")
if q.connect():
    query = {
        'Hello': '42'
    }

    task = retask.Task(query)
    q.enqueue(task)

    task = q.wait()

causes following error on my system -

Traceback (most recent call last):
  File "py/test.py", line 12, in <module>
    task = q.wait()
  File "/usr/local/lib/python3.4/dist-packages/retask/queue.py", line 159, in wait
    task.__dict__ = json.loads(data[1])
  File "/usr/lib/python3.4/json/__init__.py", line 312, in loads
    s.__class__.__name__))
TypeError: the JSON object must be str, not 'bytes'

I am running ubuntu 14.04. Retask installed using pip. Python version 3.4.3. I was able to fix the error by substituting json.loads(data[1]) to json.loads(data[1].decode()) on lines https://github.com/kushaldas/retask/blob/master/retask/queue.py#L159 and https://github.com/kushaldas/retask/blob/master/retask/queue.py#L318 .

Is that an error or am I doing it wrong?

@kushaldas kushaldas added the bug label May 12, 2016
@kushaldas
Copy link
Owner

kushaldas commented May 12, 2016

I am going to count this as an error. Sorry for missing the bug report. Just now saw this.

@JendaPlhak
Copy link
Author

Ok, should I open an pull request?

@chenxiaoqino
Copy link

I tried to fix it in PR #15 . @kushaldas

@abompard
Copy link

I'm hitting this issue too.

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

No branches or pull requests

4 participants