From: Fredrik Tolf Date: Sun, 19 Jun 2016 00:33:48 +0000 (+0200) Subject: python: Added a channel superclass for ashd.async. X-Git-Url: http://git.dolda2000.com/gitweb/?a=commitdiff_plain;h=be6ec4ec06b2f394a58aa652a22a300fae371994;p=ashd.git python: Added a channel superclass for ashd.async. --- diff --git a/python3/ashd/async.py b/python3/ashd/async.py index 3493959..4247bd6 100644 --- a/python3/ashd/async.py +++ b/python3/ashd/async.py @@ -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()