Remove legacy code from pyglet.app.
@@ -43,7 +43,6 @@ from pyglet import clock
from pyglet import event
from pyglet import compat_platform
-
_is_pyglet_doc_run = hasattr(sys, "is_pyglet_doc_run") and sys.is_pyglet_doc_run
@@ -52,6 +51,7 @@ class PlatformEventLoop:
.. versionadded:: 1.2
"""
+
def __init__(self):
self._event_queue = queue.Queue()
self._is_running = threading.Event()
@@ -161,81 +161,15 @@ class EventLoop(event.EventDispatcher):
platform_event_loop = app.platform_event_loop
platform_event_loop.start()
self.dispatch_event('on_enter')
-
self.is_running = True
- legacy_platforms = ('XP', '2000', '2003Server', 'post2003')
- if compat_platform == 'win32' and platform.win32_ver()[0] in legacy_platforms:
- self._run_estimated()
- else:
- self._run()
-
- self.is_running = False
- self.dispatch_event('on_exit')
- platform_event_loop.stop()
- def _run(self):
- """The simplest standard run loop, using constant timeout. Suitable
- for well-behaving platforms (Mac, Linux and some Windows).
- """
- platform_event_loop = app.platform_event_loop
while not self.has_exit:
timeout = self.idle()
platform_event_loop.step(timeout)
- def _run_estimated(self):
- """Run-loop that continually estimates function mapping requested
- timeout to measured timeout using a least-squares linear regression.
- Suitable for oddball platforms (Windows).
-
- XXX: There is no real relation between the timeout given by self.idle(), and used
- to calculate the estimate, and the time actually spent waiting for events. I have
- seen this cause a negative gradient, showing a negative relation. Then CPU use
- runs out of control due to very small estimates.
- """
- platform_event_loop = app.platform_event_loop
-
- predictor = self._least_squares()
- gradient, offset = next(predictor)
-
- time = self.clock.time
- while not self.has_exit:
- timeout = self.idle()
- if timeout is None:
- estimate = None
- else:
- estimate = max(gradient * timeout + offset, 0.0)
- if False:
- print('Gradient = %f, Offset = %f' % (gradient, offset))
- print('Timeout = %f, Estimate = %f' % (timeout, estimate))
-
- t = time()
- if not platform_event_loop.step(estimate) and estimate != 0.0 and estimate is not None:
- dt = time() - t
- gradient, offset = predictor.send((dt, estimate))
-
- @staticmethod
- def _least_squares(gradient=1, offset=0):
- X = 0
- Y = 0
- XX = 0
- XY = 0
- n = 0
-
- while True:
- x, y = yield gradient, offset
- X += x
- Y += y
- XX += x * x
- XY += x * y
- n += 1
-
- try:
- gradient = (n * XY - X * Y) / (n * XX - X * X)
- offset = (Y - gradient * X) / n
- except ZeroDivisionError:
- # Can happen in pathalogical case; keep current
- # gradient/offset for now.
- pass
+ self.is_running = False
+ self.dispatch_event('on_exit')
+ platform_event_loop.stop()
def _legacy_setup(self):
# Disable event queuing for dispatch_events
