Problem with sending rectangle objects across the network

53 views
Skip to first unread message

Bob Smith

unread,
Feb 1, 2018, 12:56:46 PM2/1/18
to PodSixNet
Hi, I am having problems with sending small lists of rectangles from my client to my server. I use a standard send call to send three lists filled with rectangles, looking like this:

connection.Send({"action":"board","obstructions":self.obstructions,"points":self.points,"extrapoints":self.extrapoints})

The code executes if the list of rectangle objects has 32 or more recs, but anything less than that and the program crashes with this error:

error: uncaptured python exception, closing channel <__main__.ClientChannel 127.0.0.1:56743 at 0x515a250> (<class 'KeyError'>:b'' [C:\Users\Anthony.Schmidt\AppData\Local\Programs\Python\Python36-32\lib\asyncore.py|read|83] [C:\Users\Anthony.Schmidt\AppData\Local\Programs\Python\Python36-32\lib\asyncore.py|handle_read_event|423] [C:\Users\Anthony.Schmidt\AppData\Local\Programs\Python\Python36-32\lib\asynchat.py|handle_read|171] [C:\Users\Anthony.Schmidt\AppData\Local\Programs\Python\Python36-32\lib\site-packages\podsixnet-79-py3.6.egg\PodSixNet\Channel.py|found_terminator|20] [C:\Users\Anthony.Schmidt\AppData\Local\Programs\Python\Python36-32\lib\site-packages\podsixnet-79-py3.6.egg\PodSixNet\rencode.py|loads|425] [C:\Users\Anthony.Schmidt\AppData\Local\Programs\Python\Python36-32\lib\site-packages\podsixnet-79-py3.6.egg\PodSixNet\rencode.py|f|411] [C:\Users\Anthony.Schmidt\AppData\Local\Programs\Python\Python36-32\lib\site-packages\podsixnet-79-py3.6.egg\PodSixNet\rencode.py|f_fixed_list|362])

What are some possible solutions for this? It seems odd to me that the number of rectangles in the list would change the outcome.

Chris McCormick

unread,
Feb 1, 2018, 9:05:27 PM2/1/18
to pods...@googlegroups.com, Bob Smith
Hi Bob,
On 02/02/18 01:56, Bob Smith wrote:
> connection.Send({"action":"board","obstructions":self.obstructions,"points":self.points,"extrapoints":self.extrapoints})
>
> The code executes if the list of rectangle objects has 32 or more recs,
> but anything less than that and the program crashes with this error:
>
> error: uncaptured python exception, closing channel
> <__main__.ClientChannel 127.0.0.1:56743 at 0x515a250> (<class
> 'KeyError'>:b''
> [C:\Users\Anthony.Schmidt\AppData\Local\Programs\Python\Python36-32\lib\asyncore.py|read|83]
> [C:\Users\Anthony.Schmidt\AppData\Local\Programs\Python\Python36-32\lib\asyncore.py|handle_read_event|423]
> [C:\Users\Anthony.Schmidt\AppData\Local\Programs\Python\Python36-32\lib\asynchat.py|handle_read|171]
> [C:\Users\Anthony.Schmidt\AppData\Local\Programs\Python\Python36-32\lib\site-packages\podsixnet-79-py3.6.egg\PodSixNet\Channel.py|found_terminator|20]
> [C:\Users\Anthony.Schmidt\AppData\Local\Programs\Python\Python36-32\lib\site-packages\podsixnet-79-py3.6.egg\PodSixNet\rencode.py|loads|425]
> [C:\Users\Anthony.Schmidt\AppData\Local\Programs\Python\Python36-32\lib\site-packages\podsixnet-79-py3.6.egg\PodSixNet\rencode.py|f|411]
> [C:\Users\Anthony.Schmidt\AppData\Local\Programs\Python\Python36-32\lib\site-packages\podsixnet-79-py3.6.egg\PodSixNet\rencode.py|f_fixed_list|362])
>
> What are some possible solutions for this? It seems odd to me that the
> number of rectangles in the list would change the outcome.

That does seem odd.

From what I can tell the receiving client is crashing because what is
being sent is being encoded incorrectly.

What you want to do is take a look at the `rencode` output that is being
sent across the network to determine what is different. You can do this
by patching rencode.py on the sending side to make it print out the
value before it is returned. Do this for both sets of rectangles and
examine the difference.

My hunch is that your objects may be more complex structures - the
rencoding is only designed to handle data structures composed of simple
types like dict, list, string, number.

Cheers,

Chris.

--
http://mccormick.cx/

Bob Smith

unread,
Feb 2, 2018, 3:15:34 PM2/2/18
to PodSixNet
Thanks for the help Chris, it looks like I'm going to recode it to send all the information in lists of numbers, and then rebuild the objects from the information that is transferred.

Chris McCormick

unread,
Feb 3, 2018, 1:47:58 AM2/3/18
to pods...@googlegroups.com, Bob Smith
Hi,

If you can serialize the information into basic data structures composed
of dictionaries, lists, numbers, strings, etc. then you will probably
find this issue goes away and you still get to have well structured data.

Good luck.

Cheers,

Chris.

On 03/02/18 04:15, Bob Smith wrote:
> Thanks for the help Chris, it looks like I'm going to recode it to send
> all the information in lists of numbers, and then rebuild the objects
> from the information that is transferred.
>
> On Thursday, February 1, 2018 at 6:05:27 PM UTC-8, Chris McCormick wrote:
>
> Hi Bob,
> On 02/02/18 01:56, Bob Smith wrote:
> >
> connection.Send({"action":"board","obstructions":self.obstructions,"points":self.points,"extrapoints":self.extrapoints})
>
> >
> > The code executes if the list of rectangle objects has 32 or more
> recs,
> > but anything less than that and the program crashes with this error:
> >
> > error: uncaptured python exception, closing channel
> > <__main__.ClientChannel 127.0.0.1:56743 <http://127.0.0.1:56743>
> --
> You received this message because you are subscribed to the Google
> Groups "PodSixNet" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to podsixnet+...@googlegroups.com
> <mailto:podsixnet+...@googlegroups.com>.
> To post to this group, send email to pods...@googlegroups.com
> <mailto:pods...@googlegroups.com>.
> Visit this group at https://groups.google.com/group/podsixnet.
> For more options, visit https://groups.google.com/d/optout.

--
http://mccormick.cx/
Reply all
Reply to author
Forward
0 new messages