<div dir="ltr"><div class="gmail_quote">On Fri Feb 20 2015 at 9:14:30 PM Joshua Harlow <<a href="mailto:harlowja@outlook.com">harlowja@outlook.com</a>> wrote:<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
> This feels like something we could do in the service manager base class,<br>
> maybe by adding a "post fork" hook or something.<br>
<br>
+1 to that.<br>
<br>
I think it'd be nice to have the service __init__() maybe be something like:<br>
<br>
  def __init__(self, threads=1000, prefork_callbacks=None,<br>
               postfork_callbacks=None):<br>
     self.postfork_callbacks = postfork_callbacks or []<br>
     self.prefork_callbacks = prefork_callbacks or []<br>
     # always ensure we are closing any left-open fds last...<br>
     self.prefork_callbacks.append(<u></u>self._close_descriptors)<br>
     ...<br></blockquote><div><br></div><div>(you must've meant postfork_callbacks.append)</div><div><br></div><div>Note that multiprocessing module already have `multiprocessing.util.register_after_fork` method that allows to register callback that will be called every time a Process object is run. If we remove explicit use of `os.fork` in oslo.service (replace it with Process class) we'll be able to specify any after-fork callbacks in libraries that they need. For example, EngineFacade could register `pool.dispose()` callback there (it should have some proper finalization logic though).</div><div><br></div><div>I'd also suggest to avoid closing any fds in library that it doesn't own. This would definitely give some woes to developers who would expect shared descriptors to work.</div></div></div>