Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/lothiraldan/tornado_circus
A tornado application implementation compatbile with circus sockets
https://github.com/lothiraldan/tornado_circus
Last synced: 3 days ago
JSON representation
A tornado application implementation compatbile with circus sockets
- Host: GitHub
- URL: https://github.com/lothiraldan/tornado_circus
- Owner: Lothiraldan
- Created: 2013-05-30T08:20:22.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2013-07-22T12:00:11.000Z (over 11 years ago)
- Last Synced: 2024-06-11T20:19:56.620Z (5 months ago)
- Language: Python
- Size: 82 KB
- Stars: 8
- Watchers: 4
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.rst
Awesome Lists containing this project
README
circus\_tornado
===============A tornado application implementation compatible with circus sockets.
As tornado is not WSGI complient, we cannot use chaussette to run
tornado applications with circus sockets.This project package a compatible version of tornado Application so you
can easily run tornado with all circus awesomeness.Use circus\_tornado
===================Let's take a simple example, the hello world::
import tornado.ioloop
import tornado.webfrom tornado.web import Application
class MainHandler(tornado.web.RequestHandler):
def get(self):
self.write("Hello, world")application = Application([
(r"/", MainHandler),
])if __name__ == "__main__":
application.listen(8888)
tornado.ioloop.IOLoop.instance().start()If you want to run it with circus, you can't use socket web and fallback
to launch them and let it bind its socket::[watcher:hello]
cmd = python hello_world.pyBut good news, with circus\_tornado, it's no longer true. Just import
Application from circus\_tornado package::import tornado.ioloop
import tornado.webfrom tornado_circus import Application
class MainHandler(tornado.web.RequestHandler):
def get(self):
self.write("Hello, world")application = Application([
(r"/", MainHandler),
])if __name__ == "__main__":
parse_command_line()
application.listen(8888)
tornado.ioloop.IOLoop.instance().start()One last requirement, you must call tornado.options.parse\_command\_line
**before** calling application.listen or it will doesn't works.And finally the circus configuration::
[watcher:hello]
cmd = python hello_world.py --fd=$(circus.sockets.hello)
use_sockets = True[socket:hello]
host = 127.0.0.1
port = 9000And you're done. You can go to http://localhost:9000 to check if it
works.You can even launch a quick benchmark and check that it holds the load::
$> boom -n 10000 -c 100 http://localhost:9000 10:38:48
Server Software: TornadoServer/2.4.1
Running GET http://127.0.0.1:9000
Host: localhost
Running 10000 times per 100 workers.
Starting the load [===...===] Done-------- Errors --------
-------- Results --------
Successful calls 10000
Total time 9.3364 s
Average 0.0656 s
Fastest 0.0228 s
Slowest 0.1009 s
Amplitude 0.0781 s
RPS 1071
BSI Woooooo Fast-------- Status codes --------
Code 200 10000 times.-------- Legend --------
RPS: Request Per Second
BSI: Boom Speed Index