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:
911ad7f
)
python: Gather handler names better.
author
Fredrik Tolf
<fredrik@dolda2000.com>
Sun, 5 Jan 2014 21:31:44 +0000
(22:31 +0100)
committer
Fredrik Tolf
<fredrik@dolda2000.com>
Sun, 5 Jan 2014 21:31:44 +0000
(22:31 +0100)
python3/ashd/serve.py
patch
|
blob
|
blame
|
history
diff --git
a/python3/ashd/serve.py
b/python3/ashd/serve.py
index
15e2903
..
9aae12c
100644
(file)
--- a/
python3/ashd/serve.py
+++ b/
python3/ashd/serve.py
@@
-88,6
+88,8
@@
class handler(object):
return {}
class single(handler):
return {}
class single(handler):
+ cname = "single"
+
def handle(self, req):
try:
env = req.mkenv()
def handle(self, req):
try:
env = req.mkenv()
@@
-107,6
+109,8
@@
class single(handler):
req.close()
class freethread(handler):
req.close()
class freethread(handler):
+ cname = "free"
+
def __init__(self, *, max=None, timeout=None, **kw):
super().__init__(**kw)
self.current = set()
def __init__(self, *, max=None, timeout=None, **kw):
super().__init__(**kw)
self.current = set()
@@
-179,6
+183,8
@@
class freethread(handler):
th.join()
class resplex(handler):
th.join()
class resplex(handler):
+ cname = "rplex"
+
def __init__(self, *, max=None, **kw):
super().__init__(**kw)
self.current = set()
def __init__(self, *, max=None, **kw):
super().__init__(**kw)
self.current = set()
@@
-326,9
+332,10
@@
class resplex(handler):
os.close(self.cnpipe[1])
self.rthread.join()
os.close(self.cnpipe[1])
self.rthread.join()
-names = {"single": single,
- "free": freethread,
- "rplex": resplex}
+names = {cls.cname: cls for cls in globals().values() if
+ isinstance(cls, type) and
+ issubclass(cls, handler) and
+ hasattr(cls, "cname")}
def parsehspec(spec):
if ":" not in spec:
def parsehspec(spec):
if ":" not in spec: