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

Not complete data leads to a json error #3

Open
bibile opened this issue Feb 27, 2015 · 2 comments
Open

Not complete data leads to a json error #3

bibile opened this issue Feb 27, 2015 · 2 comments

Comments

@bibile
Copy link

bibile commented Feb 27, 2015

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 :)

@baekgaard
Copy link
Owner

Thanks for the comment and apologies for the delayed response; seems like it got lost in my junk box somehow.

Anyway, I'll have a look at what happens -- it might also be that the packet is somehow split into two in the network side; this should of course be handled gracefully and the packet re-assembled before being sent to the parser.

I have never seen it on any of the machines we've been using this on. What is your setup (platform/OS)? Do you pass the packets through a "real" network or do you use the internal loopback network interface?

I'll update this issue when it's fixed.

@bibile
Copy link
Author

bibile commented Apr 10, 2015

Hi,

I am on W7-64, py27
Actually, I get this error with a specific setup:

  • eyetribe and my script on the same PC
  • my script does the connexion with eyetribe server using your module, and display some of the result (at 10Hz) in a tkinter gui

I get that error if I play to much with the gui (using my mouse).

If I do not play with the gui, no problems. Which actually work for me because it was just to show some datas.
I paste it here http://pastebin.com/jffZ5fSk
It's not my script, just a part of it as it is much longer. I hope it works still.. I do not have an eyetribe device to test it now.

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

No branches or pull requests

2 participants