[Erp5-report] r13831 - in /erp5/trunk/utils/oood: pool.py start.py
Jean-Paul Smets
jp at nexedi.com
Sun Apr 1 11:03:52 CEST 2007
I will try it. If it works, great news.
JPS.
Le samedi 31 mars 2007 12:09, nobody at svn.erp5.org a écrit :
> Author: bartek
> Date: Sat Mar 31 12:09:39 2007
> New Revision: 13831
>
> URL: http://svn.erp5.org?rev=13831&view=rev
> Log:
> fixed the zombie problem: now when oood restarts an OOo instance it
> starts a new thread which is waiting for the instance to exit, thus
> keeping it under control.
>
> Modified:
> erp5/trunk/utils/oood/pool.py
> erp5/trunk/utils/oood/start.py
>
> Modified: erp5/trunk/utils/oood/pool.py
> URL:
> http://svn.erp5.org/erp5/trunk/utils/oood/pool.py?rev=13831&r1=13830&r2=1
>3831&view=diff
> =========================================================================
>===== --- erp5/trunk/utils/oood/pool.py (original)
> +++ erp5/trunk/utils/oood/pool.py Sat Mar 31 12:09:39 2007
> @@ -113,7 +113,8 @@
> Log.warning('[pool] Instance %s not responding - restart it' % i)
> start.killInstance(i)
> self._killWorker(i)
> - start.startInstance(i)
> + # start instance and keep it under control
> + start.startInstance(i, keep_control=True)
> # give it time to load before we try to connect
> time.sleep(config.instance_load_time)
> self._mkWorker(i)
>
> Modified: erp5/trunk/utils/oood/start.py
> URL:
> http://svn.erp5.org/erp5/trunk/utils/oood/start.py?rev=13831&r1=13830&r2=
>13831&view=diff
> =========================================================================
>===== --- erp5/trunk/utils/oood/start.py (original)
> +++ erp5/trunk/utils/oood/start.py Sat Mar 31 12:09:39 2007
> @@ -31,6 +31,7 @@
> import logging
> import os
> import sys
> +import threading
> # Add oood home (= current path) as a place to look for import
> # XXX Is this magical things make oood_home parameter useless in oood
> config file ? sys.path.append(os.path.abspath(os.getcwd()))
> @@ -65,7 +66,7 @@
> Log.info('%s%s' % (LOG_HEAD, msg))
>
>
> -def startInstance(i, on_top=False):
> +def startInstance(i, on_top=False, keep_control=False):
> """
> We spawn a new process and record its pid to be able to kill it if
> necessary. """
> @@ -99,8 +100,18 @@
> _l("Listening at %s:%s" % (config.pool_host, instance_port), i)
> pidfile = os.path.join(config.run_dir, 'instance_%d.pid' % i)
> open(pidfile, 'w').write(str(pid))
> + if keep_control:
> + # if we start instance from running oood (because we did
> kill/restart), + # we have to call "wait" on it to keep it under
> control
> + # otherwise when it is killed it becomes a zombie
> + # so we establish a waiting thread, not to block the whole process
> + _l("Starting waiting thread for process %s" % pid, i)
> + waiting_thread = threading.Thread(target=justWait, args=(pid,))
> + waiting_thread.start()
> _l("Started as process %s" % pid, i)
>
> +def justWait(pid):
> + os.waitpid(pid, 0)
>
> def killInstance(i):
> _l("Kill requested", i)
>
> _______________________________________________
> Erp5-report mailing list
> Erp5-report at erp5.org
> http://www.erp5.org/mailman/listinfo/erp5-report
--
Jean-Paul Smets-Solanes, Nexedi CEO - Tel. +33(0)6 29 02 44 25
Nexedi: Consulting and Development of Libre / Open Source Software
http://www.nexedi.com
ERP5: Libre/ Open Source ERP Software for small and medium companies
http://www.erp5.org
Rentalinux: Desktop Linux Server
http://www.rentalinux.com
More information about the Erp5-report
mailing list