twisted.internet

Reconnect to different address in twisted?

99封情书 提交于 2019-12-11 07:07:09
问题 I have a server that sends my client the address of a backup server in case it goes down. On the server side the backup server is running. On the client side once the connection is lost I am not able to make the client to connect to the backup server. I know that I have to add the connection logic to the following callback in twisted.internet.protcol.Protocol class MyProtocol(Protocol): def connectionLost(self, reason): print 'Connection Lost' print 'Trying to reconnect' # How do I reconnect

How to limit the number of simultaneous connections in Twisted

三世轮回 提交于 2019-12-05 19:38:35
so I have a twisted server I built, and I was wondering what is the best way to limit the number of simultaneous connections? Is having my Factory return None the best way? When I do this, I throw a lot of exceptions like: exceptions.AttributeError: 'NoneType' object has no attribute 'makeConnection' I would like someway to have the clients just sit in queue until the current connection number goes back down, but I don't know how to do that asynchronously. Currently I am using my factory do like this: class HandleClientFactory(Factory): def __init__(self): self.numConnections = 0 def