[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] Networking library



Hi David,

I've put a bzr branch of the serialisation stuff here:

bzr co http://mccormick.cx/dev/PodSixNet.serialise/

Let me know if you need me to tar it up or whatever instead. I've had a closer
look and the issue is slightly different for each serialisation method. All
work in my unit tests, but when I run the whiteboard example everything except
json breaks. You can reproduce this by:

* Changing Channel.py to:
	'from serialise.rencode import *' or
	'from serialise.gherkin import *' or
	'from serialise.json import *'
(I'll make that easy to configure at runtime in future)
* Run the unit tests:
	python EndPoint.py
	python Server.py
* Run the examples:
	python examples/WhiteboardServer.py &
	python examples/WhiteboardClient.py &
	python examples/WhiteboardClient.py

Rencode fails on the whiteboard example because when it deserialises lists,
they are tuples by default which means you can't use them directly in your code
without turning them back into lists, unless you don't want to modify them. I
don't like that because it puts the onus on the library user to do that
tuple-to-list jiggery when it should Just Work. On the other hand, gherkin
fails with this cryptic message, only when connecting with a second client:
"ValueError("Type prefix not supported. ('\\x96')",)". So I am sending some
data down the socket which gherkin doesn't like. I am CC'ing the gherkin author
to see if he can help me decypher what's going on there. If it's a simple fix I
am probably going to go with using gherkin by default with the option of
simplejson in < py2.6, and the built-in json for >= py2.6

Patches welcome!

Best,

Chris.

On Tue, Apr 14, 2009 at 08:24:40AM -0600, David wrote:
> Chris:
> 
> Could you share your test code, that you used to evaluate gherkin and rencode?
> 
> David
> 
> On Tue, Apr 14, 2009 at 3:25 AM, Chris McCormick <chris@xxxxxxxxxxxx> wrote:
> > After talking to a friend who suggested a few different serialisation methods,
> > like gherkin, and rencode, I tried implementing a serialisation wrapper layer
> > that lets you choose how to serialise, but gherkin and rencode both didn't
> > produce the exact structures that went in, coming out, so I'm going to have to
> > work a bit harder. I will definately steer clear of repr/eval, but I might try
> > out the other snippet that was posted here. Hopefully I'll come up with
> > something faster and lighter than JSON, with the option to use JSON. Will post
> > back here if and when I get it working.
> 
> -- 
> dkeeney@xxxxxxxxxxxxxxxx
> Pitcher's Duel -> pitchersduel.python-hosting.com
-------------------
http://mccormick.cx