micro-optimize no timer case
This commit is contained in:
		| @@ -973,10 +973,12 @@ class TimerManager(object): | |||||||
|         :return: next end time, or None |         :return: next end time, or None | ||||||
|         """ |         """ | ||||||
|         queue = self._queue |         queue = self._queue | ||||||
|  |         if self._new_timers: | ||||||
|             new_timers = self._new_timers |             new_timers = self._new_timers | ||||||
|             while new_timers: |             while new_timers: | ||||||
|                 heappush(queue, new_timers.pop()) |                 heappush(queue, new_timers.pop()) | ||||||
|  |  | ||||||
|  |         if queue: | ||||||
|             now = time.time() |             now = time.time() | ||||||
|             while queue: |             while queue: | ||||||
|                 try: |                 try: | ||||||
| @@ -994,11 +996,3 @@ class TimerManager(object): | |||||||
|             return self._queue[0][0] |             return self._queue[0][0] | ||||||
|         except IndexError: |         except IndexError: | ||||||
|             pass |             pass | ||||||
|  |  | ||||||
|     @property |  | ||||||
|     def next_offset(self): |  | ||||||
|         try: |  | ||||||
|             next_end = self._queue[0][0] |  | ||||||
|             return next_end - time.time() |  | ||||||
|         except IndexError: |  | ||||||
|             pass |  | ||||||
|   | |||||||
| @@ -19,6 +19,7 @@ import os | |||||||
| import socket | import socket | ||||||
| import ssl | import ssl | ||||||
| from threading import Lock, Thread | from threading import Lock, Thread | ||||||
|  | import time | ||||||
| import weakref | import weakref | ||||||
|  |  | ||||||
| from six.moves import range | from six.moves import range | ||||||
| @@ -144,9 +145,9 @@ class LibevLoop(object): | |||||||
|  |  | ||||||
|     def _update_timer(self): |     def _update_timer(self): | ||||||
|         if not self._shutdown: |         if not self._shutdown: | ||||||
|             self._timers.service_timeouts() |             next_end = self._timers.service_timeouts() | ||||||
|             offset = self._timers.next_offset or 100000  # none pending; will be updated again when something new happens |             if next_end: | ||||||
|             self._loop_timer.start(offset) |                 self._loop_timer.start(next_end - time.time())  # timer handles negative values | ||||||
|         else: |         else: | ||||||
|             self._loop_timer.stop() |             self._loop_timer.stop() | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Adam Holmberg
					Adam Holmberg