bmuller / txyam

Yet Another Memcached (YAM) client for Python Twisted
Other
10 stars 5 forks source link

Fix for Deferred being fired twice. #4

Closed dpnova closed 11 years ago

dpnova commented 11 years ago

When the library goes into reconnect mode connectionMade can be called twice, once for the original connection and once for the new connection. This is causing the deferred to be fired twice when something goes wrong with memcached.

My understanding is that when using ReconnectingFactory the factory's buildProtocol gets called for each new connection. This means the single deferred is being returned multiple times from buildProtocol.

I'm not totally sure on the best fix, this one at least stops the deferred from being multi-fired.

bmuller commented 11 years ago

Changes merged. Thanks for finding this - the deferred in the factory was added only so the ConnectedYamClient could know when every factory had connected - which means that deferred is only needed on the first connection. Good find - and thanks for the fix!