<html><head><meta http-equiv="Content-Type" content="text/html charset=iso-8859-1"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><br><div><div>Le 6 août 2013 à 08:28, Glyph <<a href="mailto:glyph@twistedmatrix.com">glyph@twistedmatrix.com</a>> a écrit :</div><br class="Apple-interchange-newline"><blockquote type="cite"><meta http-equiv="Content-Type" content="text/html charset=iso-8859-1"><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><br><div><div>On Aug 5, 2013, at 2:09 AM, Benjamin BERTRAND <<a href="mailto:beenje@gmail.com">beenje@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div style="font-family: Menlo-Regular; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;">That's why the inlineCallbacks solves the problem. When I yield on the self.server.dataReceived, I wait for the deferred in the publish methods to fire and everything is clean when I close the connection.</div><div style="font-family: Menlo-Regular; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><br></div><div style="font-family: Menlo-Regular; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;">Is there another way to do that?</div></blockquote><br></div><div>Jonathan Lange wrote about this a long time ago:</div><div><br></div><div><a href="http://blackjml.livejournal.com/23029.html">http://blackjml.livejournal.com/23029.html</a></div></div></blockquote><div><br></div><div>Thanks for the link.</div><div>I added a deferred in my RedisPublishService class and fire it at the end of my publish method so that I can wait for it before to close the connection.</div><br><blockquote type="cite"><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div><br></div><div>but better than doing that would be to avoid setting up and tearing down real TCP connections during your tests.  Those are slower than an in-memory thing (like you would get from twisted.test.proto_helpers, the one <b>and only</b> public module in our 'test' package) and also, as you have discovered, more unpredictable.</div><div><br></div><div>Is there any way to hand txredis a synthetic transport for testing?  If not, file a bug on it :).</div></div></blockquote><div><br></div><div>I guess it's possible to use a synthetic transport, but that wouldn't help much without a "fake" redis server.</div><div>That would indeed be nice to have for testing.</div><div><br></div><div>I actually just found a dummy txredis client that implements everything internally for testing: <a href="https://github.com/williamsjj/dummy-txredis">https://github.com/williamsjj/dummy-txredis</a></div><div>Might be worth looking at.</div><div>But I wonder if implementing a basic redis server with twisted (for testing purpose) wouldn't be nicer?</div><div><br></div><div>Benjamin</div><br><blockquote type="cite"><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div><br></div><div>-glyph</div><br></div>_______________________________________________<br>Twisted-Python mailing list<br><a href="mailto:Twisted-Python@twistedmatrix.com">Twisted-Python@twistedmatrix.com</a><br>http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python<br></blockquote></div><br></body></html>