tornadoweb/tornado — pull request #1069 by drewbrew (2014-06-03 20:15:53+00:00)
Title: ioloop.py: use itertools.count() as tiebreaker to preserve FIFO in case of tie

Current implementation does not function as a FIFO. When adding multiple
timeouts with the same deadline, order is currently consistently mangled in the
event of a garbage collect.

As suggested by Ben Darnell at
https://groups.google.com/forum/#!topic/python-tornado/w8aKm6ZabUQ/discussion,
we need to add a sequence number to the Timeout class to serve as tiebreaker.
This code uses the model suggested by
https://docs.python.org/2/library/heapq.html#priority-queue-implementation-notes,
which uses itertools.count() to serve as our counter.