[openstack-dev] [all][oslo] Dealing with database connection sharing issues
Yuriy Taraday
yorik.sar at gmail.com
Sat Feb 21 15:46:09 UTC 2015
On Fri Feb 20 2015 at 9:14:30 PM Joshua Harlow <harlowja at 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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstack.org/pipermail/openstack-dev/attachments/20150221/221a879a/attachment.html>
More information about the OpenStack-dev
mailing list