سؤال

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!

هل كانت مفيدة؟

المحلول

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

نصائح أخرى

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

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.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top