reactor: Fix bug causing end() to not always work

Only set the self._process flag in run() not _dispatch_loop().

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
Kevin O'Connor 2017-04-13 13:12:46 -04:00
parent 8491b1f86a
commit 1592395036
1 changed files with 2 additions and 4 deletions

View File

@ -1,6 +1,6 @@
# File descriptor and timer event helper
#
# Copyright (C) 2016 Kevin O'Connor <kevin@koconnor.net>
# Copyright (C) 2016,2017 Kevin O'Connor <kevin@koconnor.net>
#
# This file may be distributed under the terms of the GNU GPLv3 license.
import select, math, time
@ -105,7 +105,6 @@ class SelectReactor:
self._fds.pop(self._fds.index(handler))
# Main loop
def _dispatch_loop(self):
self._process = True
self._g_dispatch = g_dispatch = greenlet.getcurrent()
eventtime = self.monotonic()
while self._process:
@ -120,6 +119,7 @@ class SelectReactor:
break
self._g_dispatch = None
def run(self):
self._process = True
g_next = ReactorGreenlet(run=self._dispatch_loop)
g_next.switch()
def end(self):
@ -145,7 +145,6 @@ class PollReactor(SelectReactor):
self._fds = fds
# Main loop
def _dispatch_loop(self):
self._process = True
self._g_dispatch = g_dispatch = greenlet.getcurrent()
eventtime = self.monotonic()
while self._process:
@ -180,7 +179,6 @@ class EPollReactor(SelectReactor):
self._fds = fds
# Main loop
def _dispatch_loop(self):
self._process = True
self._g_dispatch = g_dispatch = greenlet.getcurrent()
eventtime = self.monotonic()
while self._process: