[Twisted-Python] giving a reason when adding a timeout

Chris Withers chris at withers.org
Wed Mar 13 10:07:33 MDT 2019


>> Unless I'm missing something, Deferred.addTimeout is really unhelpful in
>> terms on providing context about *what* timed out.
>> TimeoutError(<some number>, 'Deferred') just isn't that useful.
>>
>> How come addTimeout doesn't let you specify a textual reason, or
>> otherwise provide some context about the timeout?
>>
>> Am I missing something obvious here?
> 
> I don't know what kind of context do you need :)

foo.addTimeout(myTimeout, reactor, message='never heard back')

> You can add your own errback and add your extra error handling there.

What's the must succinct way to get the above by adding an errback?

> There is also onTimeoutCancel argument.

Pretty clunky to write a whole function for either this or the errback 
just to change the useless 'Deferred' string in the current 
implementation with something useful.

> If there is anything missing from the API, feel free to send a pull
> request in GitHub.

What's the likely turn around time from me submitting a PR to when it 
ends up in a released version of Twisted that I can use?

Chris




More information about the Twisted-Python mailing list