Python SimpleHttpServer Background bug? -


I am experiencing the following problem using a very simple BaseHttpServer (code given below):

Start the server uses ./testerver.py and in the background OK and server responses to port 12121 when I reject the server still types in responses After shutting down the terminal, in the server Input / Output Error with the next request with test.log

Closes after: Steps of reconstruction:

  $ ./testersver & amp; $ Bg $ disown   

Closed terminal, send a request to the server - & gt; Server does not respond.

The only solution I found is the stdout and stderr : $ ./testersver> / dev / null 2 ​​& gt; And 1 or @ Daniel has asked to call it in the normal way with nohup

before someone has experienced this bug Or is it a desirable behavior for it, if a output is not possible, then to crash a HTTP server?


testerver.py

  #! / Usr / bin / env python import time import bhtipassar hosT_NAME = '0.0.0.0' PORT_NUMBER = 12121 class MyHandler (BaseHTTPRequestHandler): def do_HEAD (s): s.send_response (200) s.send_header ("content type",) "Text / html") s.end_headers () def do_GET (s): "" "Answer to receive a request." "S.send_response (200) s.send_header (" content-type "," text / html ") s.end_headers () s.wfile.write (" manual server success ") if __name__ == '__main__': server_class = BaseHTTPServer.HTTPServer httpd = server_class ((HOST_NAME, PORT_NUMBER), MyHandler) Try: Excluding exceptions in the form of an httpd.serve_forever () f (Excluding exceptions such as 'test.log', 'w'): f. Write (str (e))    

You can not just leave exceptions and write strings to files And redirect you to stdout and stderr from anywhere. Otherwise, any program will hang your program.Why do not you use nohup ? This is the usual way to start a program without a terminal.

This is obvious To: There is no special behavior in the HTTP server. HttpServer is logging information on the terminal, so you need to have a redirection in the terminal or file.

Comments

Popular posts from this blog

Java - Error: no suitable method found for add(int, java.lang.String) -

java - JPA TypedQuery: Parameter value element did not match expected type -

c++ - static template member variable has internal linkage but is not defined -