gmemon
gmemon

Reputation: 2731

Event Scheduling in Twisted

Thus is s a fairly basic question, but I am new to Twisted. if the the reactor loop encounters 2 callLaters for the exact same timeout value and also encounters an incoming packet, how will it schedule the 3?

Upvotes: 1

Views: 170

Answers (2)

Glyph
Glyph

Reputation: 31910

There is no definitive rule here. Different reactors may implement different strategies. In general these implementations are somewhat ad-hoc and not particularly well designed, but there isn't a lot of motivation to fix them, because most applications with deep ordering dependencies on different event sources are actually just buggy, and should be fixed not to care what order these fundamentally non-deterministic events arrive in.

Upvotes: 3

Peter Le Bek
Peter Le Bek

Reputation: 992

The callLaters would fire in the order that you registered them. The packet arrival could fire before or after the callLaters depending on the point of execution in the event loop when the packet arrives.

Upvotes: 3

Related Questions