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

reader: python3 type error in nsqlookupd response parsing #160

Merged
merged 1 commit into from
Jul 26, 2016

Conversation

mikolajb
Copy link
Contributor

Tornado's HTTPResponse body is of type bytes in Python3 and json.loads cannot be performed.

Execution of:

import tornado.ioloop
import nsq


def handler(message):
    print(message)
    return True

r = nsq.Reader(message_handler=handler,
               lookupd_http_addresses=['nsqlookupd:4161'],
               topic='test', channel='test', lookupd_poll_interval=15)
nsq.run()

tornado.ioloop.IOLoop.current().start()

Results with:

Traceback (most recent call last):
  File "/usr/local/lib/python3.5/site-packages/tornado/ioloop.py", line 604, in _run_callback
    ret = callback()
  File "/usr/local/lib/python3.5/site-packages/tornado/stack_context.py", line 275, in null_wrapper
    return fn(*args, **kwargs)
  File "/usr/local/lib/python3.5/site-packages/nsq/reader.py", line 597, in _finish_query_lookupd
    lookup_data = json.loads(response.body)
  File "/usr/local/lib/python3.5/json/__init__.py", line 312, in loads
    s.__class__.__name__))
TypeError: the JSON object must be str, not 'bytes'

Clarification of what is a type of HTTPResponse.body:
tornadoweb/tornado@d1cab4a

@mreiferson mreiferson changed the title Python3 - Type error for HTTPResponse.body, JSON object mybst be str not bytes reader: python3 type error ing nsqlookupd response parsing Jul 26, 2016
@mreiferson mreiferson changed the title reader: python3 type error ing nsqlookupd response parsing reader: python3 type error in nsqlookupd response parsing Jul 26, 2016
@mreiferson mreiferson added the bug label Jul 26, 2016
@mreiferson mreiferson merged commit 8de6848 into nsqio:master Jul 26, 2016
@mreiferson
Copy link
Member

Thanks!

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

Successfully merging this pull request may close these issues.

2 participants