frx
frx

Reputation: 492

gevent multiple StreamServer listeners

I have daemon which has connection pool to handlerSocket. I have 2 types of clients and their protocol differs. I want to setup 2 listeners which handles each protocol and shares connection pool between them. In twisted this is relatively easy to accomplish, but couldn't find out how to do this in gevent. Thanks!

Upvotes: 3

Views: 1835

Answers (3)

arilou
arilou

Reputation: 475

I think the problem will come from the StreamServer's stop() method. It kills the pool, so, finishing one of listeners will drop all connections, from both listeners. If this is does not frighten you, you can simply pass the same Pool object to both StreamServers, running each of them in the separate greenlet.

Upvotes: 0

Denis
Denis

Reputation: 3780

In addition to frx's answer, here's a class to manage multiple servers: https://gist.github.com/1008826

Upvotes: 5

frx
frx

Reputation: 492

first instance of StreamServer could be started with: server.start() and second with server2.serve_forever()

Upvotes: 5

Related Questions