X-Git-Url: http://www.dolda2000.com/gitweb/?a=blobdiff_plain;f=python3%2Fashd%2Fasync.py;h=e30f858a3a80b8866b312c627f2a38dd425a027f;hb=8963785b76b15436bbbf06a26fc1c560ee57496e;hp=3493959aca15079814eac00406e9378c6ed6fef2;hpb=9000767562d69ddfab2674516146dacf63a6f644;p=ashd.git diff --git a/python3/ashd/async.py b/python3/ashd/async.py index 3493959..e30f858 100644 --- a/python3/ashd/async.py +++ b/python3/ashd/async.py @@ -26,7 +26,7 @@ class epoller(object): def exception(self, ch, *exc): self.remove(ch) if self.exc_handler is None: - traceback.print_exception(exc) + traceback.print_exception(*exc) else: self.exc_handler(ch, *exc) @@ -165,12 +165,25 @@ class epoller(object): def watcher(): return epoller() -class sockbuffer(object): - def __init__(self, sk): - self.sk = sk +class channel(object): + readable = False + writable = False + + def __init__(self): + self.watcher = None + + def fileno(self): + raise NotImplementedError("fileno()") + + def close(self): + pass + +class sockbuffer(channel): + def __init__(self, socket, **kwargs): + super().__init__(**kwargs) + self.sk = socket self.eof = False self.obuf = bytearray() - self.watcher = None def fileno(self): return self.sk.fileno() @@ -211,8 +224,9 @@ class sockbuffer(object): self.obuf[:] = b"" self.eof = True -class callbuffer(object): - def __init__(self): +class callbuffer(channel): + def __init__(self, **kwargs): + super().__init__(**kwargs) self.queue = [] self.rp, self.wp = os.pipe() self.lock = threading.Lock()