I have written a simple http server by extending BaseHTTPRequestHandler
. I am able to start it and process requests successfully. However it runs in the foreground, and the only way I can think of making it run in the background is to wrap it with a shell script and use nohup
, &
etc
Is there any way I can do this within the python script itself?
Asked
Active
Viewed 112 times
1

Rnet
- 4,796
- 9
- 47
- 83
-
You'll want to look into the multiprocessing module. – John Jul 13 '13 at 01:04
-
@johnthexiii as far as I understand multithreading will still keep the program in foreground, this is true in many languages, ex: in java I can start a thread but my main program stays in the foreground still, correct me if I'm wrong. – Rnet Jul 13 '13 at 01:15
-
Check out the python daemon module. – tdelaney Jul 13 '13 at 01:26
-
Sorry misread you question, anyways if you're on a *nix system you'll want to look into daemons, if you're on windows look into [services](http://stackoverflow.com/questions/32404/can-i-run-a-python-script-as-a-service-in-windows-how). – John Jul 13 '13 at 01:26