X-Git-Url: http://www.dolda2000.com/gitweb/?p=ashd.git;a=blobdiff_plain;f=python3%2Fashd%2Fasync.py;fp=python3%2Fashd%2Fasync.py;h=99da89af0d7bdc6e656ec968412b7b8b5dcfcf0f;hp=e30f858a3a80b8866b312c627f2a38dd425a027f;hb=407963f25c664cd1450ec5f6eeb80c449ff57e74;hpb=8963785b76b15436bbbf06a26fc1c560ee57496e diff --git a/python3/ashd/async.py b/python3/ashd/async.py index e30f858..99da89a 100644 --- a/python3/ashd/async.py +++ b/python3/ashd/async.py @@ -3,12 +3,15 @@ import sys, os, errno, threading, select, traceback class epoller(object): exc_handler = None - def __init__(self): + def __init__(self, check=None): self.registered = {} self.lock = threading.RLock() self.ep = None self.th = None self.stopped = False + self.loopcheck = set() + if check is not None: + self.loopcheck.add(check) self._daemon = True @staticmethod @@ -56,6 +59,8 @@ class epoller(object): self.ep = ep while self.registered: + for ck in self.loopcheck: + ck(self) if self.stopped: self._closeall() break @@ -278,8 +283,7 @@ class callbuffer(channel): self.wp = -1 def currentwatcher(io, current): - def run(): - while current: - current.wait() - io.stop() - threading.Thread(target=run, name="Current watcher").start() + def check(io): + if not current: + io.stop() + io.loopcheck.add(check)