pdm = None
def usage(out):
- out.write("usage: ashd-wsgi3 [-hAL] [-m PDM-SPEC] [-p MODPATH] [-l REQLIMIT] HANDLER-MODULE [ARGS...]\n")
+ out.write("usage: ashd-wsgi3 [-hAL] [-m PDM-SPEC] [-p MODPATH] [-t REQUEST-HANDLER[:PAR[=VAL](,PAR[=VAL])...]] HANDLER-MODULE [ARGS...]\n")
-reqlimit = 0
+hspec = "free", {}
modwsgi_compat = False
setlog = True
-opts, args = getopt.getopt(sys.argv[1:], "+hALp:l:m:")
+opts, args = getopt.getopt(sys.argv[1:], "+hALp:t:m:")
for o, a in opts:
if o == "-h":
usage(sys.stdout)
setlog = False
elif o == "-A":
modwsgi_compat = True
- elif o == "-l":
- reqlimit = int(a)
+ elif o == "-t":
+ hspec = ashd.serve.parsehspec(a)
elif o == "-m":
if pdm is not None:
pdm.srv.listen(a)
env["wsgi.run_once"] = False
return env
-if reqlimit != 0:
- guard = ashd.serve.abortlimiter(reqlimit).call
-else:
- guard = lambda fun: fun()
-
def recode(thing):
if isinstance(thing, collections.ByteString):
return thing
else:
return str(thing).encode("latin-1")
-reqhandler = ashd.serve.freethread()
-
class request(ashd.serve.wsgirequest):
def __init__(self, *, bkreq, **kw):
super().__init__(**kw)
def handle(req):
reqhandler.handle(request(bkreq=req, handler=reqhandler))
+if hspec[0] not in ashd.serve.names:
+ sys.stderr.write("ashd-wsgi3: no such request handler: %s\n" % hspec[0])
+ sys.exit(1)
+hclass = ashd.serve.names[hspec[0]]
+try:
+ hargs = hclass.parseargs(**hspec[1])
+except ValueError as exc:
+ sys.stderr.write("ashd-wsgi3: %s\n" % exc)
+ sys.exit(1)
+
+reqhandler = hclass(**hargs)
try:
ashd.util.serveloop(handle)
finally: