From 1592395036677f4c5959d947bac62a419134600b Mon Sep 17 00:00:00 2001 From: Kevin O'Connor Date: Thu, 13 Apr 2017 13:12:46 -0400 Subject: [PATCH] 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 --- klippy/reactor.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/klippy/reactor.py b/klippy/reactor.py index 65536616..9bce6a9b 100644 --- a/klippy/reactor.py +++ b/klippy/reactor.py @@ -1,6 +1,6 @@ # File descriptor and timer event helper # -# Copyright (C) 2016 Kevin O'Connor +# Copyright (C) 2016,2017 Kevin O'Connor # # 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: