The socket is fixed normally, but there are other problems with your code.
The first is
def fetch(url): g = gevent.spawn(urllib2.urlopen, url) return g.get().read()
coincides with
def fetch(url): return urllib2.urlopen(url).read()
Here you create a new green, but then block the current one until this new one is executed. This does not make things parallel. This is just like starting urlopen and waiting for it to complete.
Secondly, in order to take advantage of gevent , at the same time there must be more than one thread (greenlet).
SimpleXMLRPCServer, however, is defined as
class SimpleXMLRPCServer(SocketServer.TCPServer, SimpleXMLRPCDispatcher):
which means that it serves one connection at a time.
If you create your own SimpleXMLRPCServer class, but use ThreadingTCPServer instead of TCPServer , you can use gevent here.
monkey.patch_all() patches threading to become fundamental, so that such a server will generate new greens for each new connection.
source share