From 2ec2cee2403b531a6c5da785a55cb61aa1ddae31 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kevin=20K=C3=B6ck?= Date: Sat, 28 Dec 2019 16:54:50 +0100 Subject: [PATCH] Update event.py Increase CPython compatibility by using a boolean value for the state. Compatibility also achieveable by only changing is_set() to "return self.state==1" so it returns a boolean. self.state should never be accessed directly from the outside so could stay an integer. --- uasyncio_iostream/uasyncio/event.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/uasyncio_iostream/uasyncio/event.py b/uasyncio_iostream/uasyncio/event.py index 50870ce..9b4bd7a 100644 --- a/uasyncio_iostream/uasyncio/event.py +++ b/uasyncio_iostream/uasyncio/event.py @@ -4,16 +4,16 @@ import uasyncio class Event(uasyncio.Primitive): def __init__(self): super().__init__() - self.state = 0 # 0=unset; 1=set + self.state = False def set(self): # Event becomes set, schedule any tasks waiting on it self.run_all() - self.state = 1 + self.state = True def clear(self): - self.state = 0 + self.state = False def is_set(self): return self.state # CPython compatibility async def wait(self): - if self.state == 0: + if not self.state: # Event not set, put the calling task on the event's waiting queue self.save_current() yield