[Twisted-Python] SNMPProtocol, request for review...
Andrew Bennetts
andrew-twisted at puzzling.org
Sun Nov 2 15:20:27 MST 2003
On Sun, Nov 02, 2003 at 01:56:15PM -0500, Mike C. Fletcher wrote:
> I'm particularly interested in:
>
> * whether the timeouts are handled properly (we do a crude callLater
> and check for deferred.called for them), is there a more elegant
> Twisted mechanism for handling timed-out operations?
I haven't yet looked at your code, but there is a .setTimeout method on
Deferreds that sounds applicable here. By default it will errback your
deferred with a defer.TimeoutError, but you can pass in a custom timeoutFunc
if necessary.
One thing to watch out for when using setTimeout is that you need to wrap
your calls to d.callback/d.errback in try/except defer.AlreadyCalledError,
in case the timeout does happen (alternatively you could pass in a
timeoutFunc that arranges for whatever would call callback/errback to be
cancelled, but that might be harder). This is probably already the case
with your existing timeouts, though.
> * whether the message IDs are handled properly (we just store all
> "live" messages in a dictionary and delete them when they are
> timed out or responded to), is there some more elegant Twisted
> solution?
Again, I haven't looked at your code, but that sounds ok to me :)
-Andrew.
More information about the Twisted-Python
mailing list