Opened 4 years ago

Last modified 4 years ago

#8488 enhancement new

twisted.protocols.policies.TimeoutMixin does not accept a reactor on its constructor.

Reported by: Cory Benfield Owned by:
Priority: normal Milestone:
Component: core Keywords:
Cc: Branch:
Author:

Description

Encountered while writing tests for #8481.

TimeoutMixin is a useful feature, however it makes testing somewhat awkward. This is because it implements its functionality using reactor.callLater. Obviously, for testing this it's not ideal to wait around an actual amount of time, so we'd like to use twisted.internet.task.Clock in this case. *Unfortunately*, the callLater method on TimeoutMixin *always* calls reactor.callLater on the reactor returned by running from twisted.internet import reactor. This is really frustrating, because it forces us to patch the callLater method to point to our inserted reactor.

This is doubly problematic *outside* of the testing ecosystem: given that most classes (e.g. H2Connection) allow you to pass a reactor into them, it's going to surprise people that if those classes support a mixin like TimeoutMixin that the timeouts will *not* respect the explicit reactor.

Change History (1)

comment:1 Changed 4 years ago by Glyph

Encountered again on #8902

Note: See TracTickets for help on using tickets.