def testplot(request): """This is a web framework handler.""" from WWW.framework import HttpResponse args = (1,) proc = proctools.coprocess(makeplot, args) out = proc.read() proc.wait() # render to response return HttpResponse(out, mimetype="image/png")
def test_method(self): sub = proctools.coprocess(_co_function) self.info("childpid: %s (will exit in 5 seconds)" % (sub.childpid,)) line = sub.readline() es = sub.wait() if es: if line == "hello from co_function\r\n": # CR added by pty return self.passed("coprocess started and exited") else: self.diagnostic(repr(line)) return self.failed("bad string returned.") else: self.diagnostic(es) return self.failed("coprocess failed.")