# the CherryPy server code: #!/usr/bin/env python import random, string import cherrypy from cherrypy import expose, tools conf = {"global" : {"server.socket_port" : 8080, "server.socket_host" : "0.0.0.0"}} class Query(object): @expose def foo(self): qux = ''.join(random.choice(string.lowercase) for i in xrange(5)) + '\n' self.qux = qux return qux @expose def bar(self): return self.qux cherrypy.quickstart(Query(), config=conf) $ for i in {1..20}; do curl http://localhost:8080/foo >> res.txt & curl http://localhost:8080/bar >> res.txt; echo '-----' >> res.txt; done $ cat res.txt wutbd wutbd ----- juzgg juzgg ----- gfchl gfchl ----- yklzf yklzf ----- cqxqc cqxqc ----- cqxqc ----- gsbxi gsbxi ----- jzlyp chslm chslm ----- plllm plllm ----- plllm ----- lkoac lkoac hlssb ----- hlssb haiqi ----- ksdlg ----- ksdlg ----- ksdlg kgaej kgaej ----- kqocb kqocb ----- zlrvv shcjm shcjm ----- shcjm ----- crani ----- pfyim crani fjlac fjlac -----