Dolda2000 GitWeb
/
ashd.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
4350acb
)
python: Added a channel superclass for ashd.async.
author
Fredrik Tolf
<fredrik@dolda2000.com>
Sun, 19 Jun 2016 00:33:48 +0000
(
02:33
+0200)
committer
Fredrik Tolf
<fredrik@dolda2000.com>
Sun, 19 Jun 2016 00:33:48 +0000
(
02:33
+0200)
python3/ashd/async.py
patch
|
blob
|
blame
|
history
diff --git
a/python3/ashd/async.py
b/python3/ashd/async.py
index
3493959
..
4247bd6
100644
(file)
--- a/
python3/ashd/async.py
+++ b/
python3/ashd/async.py
@@
-165,12
+165,25
@@
class epoller(object):
def watcher():
return epoller()
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.eof = False
self.obuf = bytearray()
- self.watcher = None
def fileno(self):
return self.sk.fileno()
def fileno(self):
return self.sk.fileno()
@@
-211,8
+224,9
@@
class sockbuffer(object):
self.obuf[:] = b""
self.eof = True
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()
self.queue = []
self.rp, self.wp = os.pipe()
self.lock = threading.Lock()