Merge pull request #12 from kevinkk525/patch-1

Update event.py
pull/13/head
Peter Hinch 2019-12-29 12:03:01 +00:00 zatwierdzone przez GitHub
commit 4d2a52d109
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
1 zmienionych plików z 4 dodań i 4 usunięć

Wyświetl plik

@ -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