This makes sense. Thank you. On Thursday, November 29, 2012 4:41:56 AM UTC-5, Graham Dumpleton wrote: > > > > > On 29 November 2012 01:35, caelumvox <[email protected] <javascript:>>wrote: > >> Hello >> >> I am using apache2, mod_wsgi, and django. In my Django code, I do lots >> of os.system() and subprocess.Popen() calls which may create background >> processes. My question is, is it possible to configure mod_wsgi to close >> open file descriptors before doing an exec()? Would apache have some sort >> of option like this? >> > > No, there is not such ability in Apache or mod_wsgi. > > >> I would think that this capability could only be available in daemon >> mode. Could daemon mode close all file descriptors except 0, 1, 2, and the >> domain socket to apache? >> > > No. There is no way to know which file descriptors it is safe to close and > one even has to be careful about assuming 0, 1 and 2 will behave like a > normal stdin, stdout and stderr. > > >> I know of the subprocess.Popen(..., close_fds=True) argument in python, >> but I am trying to avoid having to pass this argument for each call. >> > > Overall best practice is that you should do sub process creation from web > server processes. This isn't just because of potential for open file > descriptors for sockets, log files and shared memory, but also because you > can inherit signals in a blocked state that can interfere with the > execution of sub processes. This latter issue make it very hard to run > certain Java applications as sub processes which rely on signals for some > aspect of GC. > > The recommended approach is to have a backend service with a less > complicated inherited environment and communicate with it to perform the > task, including execution of sub processes as necessary. > > Graham >
-- You received this message because you are subscribed to the Google Groups "modwsgi" group. To view this discussion on the web visit https://groups.google.com/d/msg/modwsgi/-/xVBpH2oZRuoJ. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/modwsgi?hl=en.
