Skip to content

Not complete data leads to a json error #3

@bibile

Description

@bibile

Hi,

Line 417, I added a print:

                            print 'JS:', js
                            f = json.loads(js)

Because sometimes, I got an error there.
It appends when the data are not complete.
Sample:

JS: {"category":"tracker","request":"get","statuscode":200,"
Exception in thread Thread-1:
Traceback (most recent call last):
  File "C:\Python27\lib\threading.py", line 808, in __bootstrap_inner
    self.run()
  File "C:\Python27\lib\threading.py", line 761, in run
    self.__target(*self.__args, **self.__kwargs)
  File "...test\peyetribe.py", line 418, in _listener_thread
    f = json.loads(js)
  File "C:\Python27\lib\json\__init__.py", line 338, in loads
    return _default_decoder.decode(s)
  File "C:\Python27\lib\json\decoder.py", line 365, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "C:\Python27\lib\json\decoder.py", line 381, in raw_decode
    obj, end = self.scan_once(s, idx)
ValueError: end is out of bounds

Can see that the message is troncated, ##{"category":"tracker","request":"get","statuscode":200,"##
Then, json decoder fail.

Maybe should put a try/except block :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions