tinyp2p - trying to get it to work
Fantus
fantus at poczta.fm
Tue Oct 9 16:01:47 EDT 2007
Marc Christiansen pisze:
>
> I had a (not so quick) look. The code proves its point (i.e. writing a
> very small p2p application is possible), but it is horrible. With only
> one server, the code is broken; maybe it works using multiple servers, I
> didn't test. A quick fix seems to be to change the line
> pr() and [aug(s) for s in aug(pr()[0])]
> to
> pr() and [aug(s) for s in aug(pr()[0])] or pr([myU])
>
> Please don't take tinyp2p.py as an example on writing python.
>
> HTH Marc
Ok, this seems to work "fine" (as much as a program designed to be
minimalistic can do) except it can't download files larger than 10kb.
It looks like a problem with SimpleXMLRPCServer (or at least I think so...)
While trying to download file larger than 10kb the server itself doesn't
crash but generates output like this:
----------------------------------------
Exception happened during processing of request from ('127.0.0.1', 44817)
Traceback (most recent call last):
File "SocketServer.py", line 222, in handle_request
self.process_request(request, client_address)
File "SocketServer.py", line 241, in process_request
self.finish_request(request, client_address)
File "SocketServer.py", line 254, in finish_request
self.RequestHandlerClass(request, client_address, self)
File "SocketServer.py", line 521, in __init__
self.handle()
File "BaseHTTPServer.py", line 316, in handle
self.handle_one_request()
File "BaseHTTPServer.py", line 310, in handle_one_request
method()
File "SimpleXMLRPCServer.py", line 445, in do_POST
self.wfile.write(response)
File "socket.py", line 248, in write
self.flush()
File "socket.py", line 235, in flush
self._sock.sendall(buffer)
error: (104, 'Connection reset by peer')
----------------------------------------
The client that was trying to make a download generates this:
Traceback (most recent call last):
File "backup5.py", line 75, in ?
(lambda fi:fi.write(proxy(url).f(pw(url),2,fn)) or
fi.close())(file(fn,"wc"))
File "backup5.py", line 75, in <lambda>
(lambda fi:fi.write(proxy(url).f(pw(url),2,fn)) or
fi.close())(file(fn,"wc"))
File "/usr/lib/python2.4/xmlrpclib.py", line 1096, in __call__
return self.__send(self.__name, args)
File "/usr/lib/python2.4/xmlrpclib.py", line 1383, in __request
verbose=self.__verbose
File "/usr/lib/python2.4/xmlrpclib.py", line 1147, in request
return self._parse_response(h.getfile(), sock)
File "/usr/lib/python2.4/xmlrpclib.py", line 1281, in _parse_response
p.feed(response)
File "/usr/lib/python2.4/xmlrpclib.py", line 527, in feed
self._parser.Parse(data, 0)
xml.parsers.expat.ExpatError: not well-formed (invalid token): line 5,
column 15
Should I post this in a separate thread or maybe one of experts visiting
this group will take a look and hopefully solve my problem?
Thank you in advance.
More information about the Python-list
mailing list