Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Fetching contributors…
Cannot retrieve contributors at this time
23 lines (17 sloc) 772 Bytes
import heapq
class FutureEventsQueue(object):
def __init__(self):
self._priority_queue = []
def schedule_event(self, event):
# in case we have two events scheduled to happen at the same time
# and we want/need one to happen before the other, we schedule
# first according to the time and second according to the number
# of the event (ie, event #1 before event #2)
((event.time,, event))
def next_event(self):
event_tuple = heapq.heappop(self._priority_queue)
event = event_tuple[1]
return event
def has_events(self):
return len(self._priority_queue) > 0
Jump to Line
Something went wrong with that request. Please try again.