From 241e7b1a3baa1a13411f6e42034c1b450d6fbf81 Mon Sep 17 00:00:00 2001 From: Paul Sokolovsky Date: Mon, 22 May 2017 13:49:27 +0300 Subject: [PATCH] uasyncio.core: Add stop() method for loop. To allow to stop loop from a callback function. --- uasyncio.core/uasyncio/core.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/uasyncio.core/uasyncio/core.py b/uasyncio.core/uasyncio/core.py index feb0d50a..a3494ab5 100644 --- a/uasyncio.core/uasyncio/core.py +++ b/uasyncio.core/uasyncio/core.py @@ -128,6 +128,9 @@ class EventLoop: self.call_soon(_run_and_stop()) self.run_forever() + def stop(self): + self.call_soon((lambda: (yield StopLoop(0)))()) + def close(self): pass