If you want to use reloading with a different WSGI server, you can use werkzeug.serving.run_with_reloader directly.
For example, this snippet uses one of gevent's WSGIServers:
import gevent.wsgi
import werkzeug.serving
@werkzeug.serving.run_with_reloader
def runServer():
app.debug = True
ws = gevent.wsgi.WSGIServer(('', 5000), app)
ws.serve_forever()
This snippet by Shane Holloway can be used freely for anything you like. Consider it public domain.
Comments
Comment by Dan Korostelev on 2011-07-22 @ 10:58
Unfortunately, this does not work for me. Gevent's hub raises
NotImplementedError: gevent is only usable from a single thread
Do I need to use gevent monkeypatching to make it actually work?
Comment by sib on 2011-09-26 @ 01:19
I can confirm that this works after calling gevent's monkey.patch_all()
Precision... by abulte on 2012-11-30 @ 12:48
Import detail: I'm using socketio.server.SocketIOServer as wsgi server...
Debug mode with SocketIOServer by abulte on 2012-11-30 @ 13:14
Found the solution : use werkzeug.debug.DebuggedApplication like described here at http://werkzeug.pocoo.org/docs/debug/
Debug mode? by abulte on 2012-11-30 @ 12:47
With this method, I get autoreload : thanks!
But I lost the beautiful werkzeug debug page when an error occurs... Despite the use of app.debug = True. The page just displays "Internal Server Error". Any tip?
Debug mode by Hasen el Judy on 2012-12-13 @ 04:54
Thank abulte for the tip!
Here's how I managed to run the socketio server without losing debugging and autoreloading:
from socketio.server import SocketIOServer from werkzeug.debug import DebuggedApplication
@werkzeug.serving.run_with_reloader def runDebugServer(): app.debug = True dapp = DebuggedApplication(app, evalex=True) SocketIOServer(('', PORT), dapp, resource="socket.io").serve_forever()
the code again .. by Hasen el Judy on 2012-12-13 @ 04:55
ok, this comment box does not like code!
Here's the snippet again:
http://hastebin.com/luduhexiso.py
nope, breaks sockets by Hasen el Judy on 2012-12-13 @ 05:50
My bad for commenting hastily without checking first.
My snippet breaks sockets!