Gevent multiple StreamServer listeners

I have a daemon that has a connection pool for handlerSocket. I have 2 types of clients and their protocol is different. I want to configure 2 listeners that processes each protocol and shares a connection pool between them. In a twisted form, this is relatively easy to accomplish, but it was not possible to figure out how to do this in gevent. Thank!

+3
source share
3 answers

The first StreamServer instance can be started with: server.start (), and the second with server2.serve_forever ()

+4
source

In addition to frx answer, here is a class for managing multiple servers: https://gist.github.com/1008826

+4
source

I think the problem will arise from the StopServer stop () method. It kills the pool, so finishing one of the listeners will drop all connections from both listeners. If this does not scare you, you can simply transfer the same pool object for both StreamServers by running each of them in a separate landscape garden.

0
source

All Articles