Advertisement
Guest User

Untitled

a guest
Apr 12th, 2014
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.37 KB | None | 0 0
  1. (gunicorn) ~/mess/gunicorn $ cat tornado_app.py
  2. from tornado.web import RequestHandler, asynchronous, Application
  3. from tornado.ioloop import IOLoop
  4.  
  5. import time
  6. from datetime import timedelta
  7. import os
  8.  
  9. class MainHandler(RequestHandler):
  10. #@asynchronous
  11. def get(self):
  12. print "GET start"
  13. print "pid: "+str(os.getpid())
  14. #def complete_req():
  15. # self.write("Hello, world.<br>pid: "+str(os.getpid()))
  16. # self.finish()
  17. # print "GET actual finish"
  18.  
  19. #IOLoop.instance().add_timeout(timedelta(0, 5), complete_req)
  20. time.sleep(3)
  21. self.write("Hello, world.<br>pid: "+str(os.getpid()))
  22. print "GET finish"
  23.  
  24. app = Application([
  25. (r"/", MainHandler)
  26. ])
  27. (gunicorn) ~/mess/gunicorn $ gunicorn -k tornado tornado_app:app -w 4
  28. 2014-04-12 20:57:52 [30465] [INFO] Starting gunicorn 18.0
  29. 2014-04-12 20:57:52 [30465] [INFO] Listening at: http://127.0.0.1:8000 (30465)
  30. 2014-04-12 20:57:52 [30465] [INFO] Using worker: tornado
  31. 2014-04-12 20:57:52 [30474] [INFO] Booting worker with pid: 30474
  32. 2014-04-12 20:57:52 [30475] [INFO] Booting worker with pid: 30475
  33. 2014-04-12 20:57:52 [30476] [INFO] Booting worker with pid: 30476
  34. 2014-04-12 20:57:52 [30477] [INFO] Booting worker with pid: 30477
  35. GET start
  36. pid: 30474
  37. GET finish
  38. GET start
  39. pid: 30474
  40. GET finish
  41. GET start
  42. pid: 30474
  43. GET finish
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement