Ticket #321: restart_test.py
| Line | |
|---|---|
| 1 | import cherrypy |
| 2 | import threading |
| 3 | import time |
| 4 | |
| 5 | class Test: |
| 6 | @cherrypy.expose |
| 7 | def restart(self): |
| 8 | cherrypy.server.restart() |
| 9 | return "restarting..." |
| 10 | |
| 11 | @cherrypy.expose |
| 12 | def stop(self): |
| 13 | cherrypy.server.stop() |
| 14 | return "stopping..." |
| 15 | |
| 16 | @cherrypy.expose |
| 17 | def test_suspend_resume(self): |
| 18 | cherrypy.server.suspend() |
| 19 | yield "server suspended" |
| 20 | time.sleep(5) |
| 21 | cherrypy.server.resume() |
| 22 | yield "server resumed" |
| 23 | |
| 24 | t = threading.currentThread() |
| 25 | |
| 26 | cherrypy.root = Test() |
| 27 | |
| 28 | cherrypy.config.update( |
| 29 | {'global': |
| 30 | {'autoreload.on':False} |
| 31 | } |
| 32 | ) |
| 33 | |
| 34 | print t.getName(), 'started.' |
| 35 | cherrypy.server.start() |
| 36 | print t.getName(), 'stopped.' |

