I wrote a simple HTTP server in python to manage a database hosted on a server through a web interface. It works great and works as intended. However, he has one huge problem, it will not remain. It will work for an hour or so, but if you remain unused for extended periods of time when you return to using it, I must reinitialize it every time. Currently, the method I use to feed it is as follows:
def main(): global db db = DB("localhost") server = HTTPServer(('', 8080), MyHandler) print 'started httpserver...' server.serve_forever() if __name__ == '__main__': main()
I run this in the background on a linux server, so I run a command like sudo python webserver.py and turn it off, but as I mentioned earlier, after a while it shuts down. Any advice is welcome because it is standing, I do not understand why it is closing.
source share