[Twisted-Python] Twisted Names Deprecation Warning Fixes

Peter Kropf peterk at bayarea.net
Wed Mar 23 13:21:32 MST 2005


                                                                          
Ok.

Out of curiousity, how would I find out the public API?

- Peter


Andrew Bennetts wrote:
> On Wed, Mar 23, 2005 at 05:49:47AM -0800, Peter Kropf wrote:
> [...]
> 
>>@@ -1123,8 +1124,13 @@
>>             self.resends[id] = 1
>>         m = Message(id, recDes=1)
>>         m.queries = queries
>>-        d = self.liveMessages[id] = defer.Deferred()
>>-        d.setTimeout(timeout, self._clearFailed, id)
>>+
>>+        from twisted.internet import reactor
>>+        d = defer.Deferred()
>>+        timeoutCall = reactor.callLater(
>>+            timeout,
>>+            lambda: d.called or self._clearFailed( d, id ) )
>>+        self.liveMessages[id] = ( d, timeoutCall )
>>         self.writeMessage(m, address)
>>         return d
> 
> 
> I think this would be better as:
> 
>         from twisted.internet import reactor
>         d = defer.Deferred()
>         timeoutCall = reactor.callLater(timeout, self._clearFailed, d, id)
>         def cancelTimeout(result, timeoutCall=timeoutCall):
>             timeoutCall.cancel()
>             return result
>         d.addBoth(cancelTimeout)
>         self.liveMessages[id] = ( d, timeoutCall )
> 
> 'called' is not part of Deferred's public API.
>         
> -Andrew.
> 
> 
> _______________________________________________
> Twisted-Python mailing list
> Twisted-Python at twistedmatrix.com
> http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
> 




More information about the Twisted-Python mailing list