On Fri Feb 20 2015 at 9:14:30 PM Joshua Harlow <harlo...@outlook.com> wrote:
> > This feels like something we could do in the service manager base class,
> > maybe by adding a "post fork" hook or something.
> +1 to that.
> I think it'd be nice to have the service __init__() maybe be something
> like:
>   def __init__(self, threads=1000, prefork_callbacks=None,
>                postfork_callbacks=None):
>      self.postfork_callbacks = postfork_callbacks or []
>      self.prefork_callbacks = prefork_callbacks or []
>      # always ensure we are closing any left-open fds last...
>      self.prefork_callbacks.append(self._close_descriptors)
>      ...

(you must've meant postfork_callbacks.append)

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).

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.
OpenStack Development Mailing List (not for usage questions)
Unsubscribe: openstack-dev-requ...@lists.openstack.org?subject:unsubscribe

Reply via email to