Bug#575293: [Pkg-freevo-maint] Bug#575293: python-kaa-base: integration with twisted does not work anymore
hi, thanks a lot for the detailed analysis On Wed, Mar 24, 2010 at 09:14:20PM +0100, Mickael Royer wrote: More information : The problem does not appear in version 0.6.0-2 and is due to this diff : diff -ru kaa/process.py kaa--new/process.py [...] yes, this was added in the hope of supporting architectures with different libc When we import kaa, this code is called and ctypes.util.find_library call popen function which force kaa notifier init. do you mean that the call os.popen in line 55 in /usr/lib/python2.5/ctypes/util.py triggers an initialization of kaa notifier ? how does this happen? can it be avoided? a. -- To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org
Bug#575293: [Pkg-freevo-maint] Bug#575293: python-kaa-base: integration with twisted does not work anymore
Hi, do you mean that the call os.popen in line 55 in /usr/lib/python2.5/ctypes/util.py triggers an initialization of kaa notifier ? how does this happen? It happens like that : 1. import kaa 2. in kaa/__init__.py line 39 from async import ... 3. in kaa/async.py line 977 import main 4. in kaa/main.py line 30 from process import supervisor 5. in kaa/process.py line 182 supervisor = _Supervisor 6. in kaa/process.py line 64 in constructor of _Supervisor : signal.signal(signal.SIGCHLD, self._sigchld_handler) So kaa check SIGHDL (signal sent to a process when a child process terminates). Just after that (in the same function, line 79) we call ctypes.util.find_library which call popen. When popen finished, SIGHDL is raised, so self._sigchld_handler is called and the notifier is initialized. can it be avoided? The solution I see is to load libc library with ctypes just before start to handle SIGHDL signal. I try quickly and it seems to work well. Cheers Mickaël On Thu, Mar 25, 2010 at 9:44 AM, A Mennucc deb...@tonelli.sns.it wrote: hi, thanks a lot for the detailed analysis On Wed, Mar 24, 2010 at 09:14:20PM +0100, Mickael Royer wrote: More information : The problem does not appear in version 0.6.0-2 and is due to this diff : diff -ru kaa/process.py kaa--new/process.py [...] yes, this was added in the hope of supporting architectures with different libc When we import kaa, this code is called and ctypes.util.find_library call popen function which force kaa notifier init. do you mean that the call os.popen in line 55 in /usr/lib/python2.5/ctypes/util.py triggers an initialization of kaa notifier ? how does this happen? can it be avoided? a. -- To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org
Bug#575293: [Pkg-freevo-maint] Bug#575293: python-kaa-base: integration with twisted does not work anymore
It happens like that : 1. import kaa 2. in kaa/__init__.py line 39 from async import ... 3. in kaa/async.py line 977 import main 4. in kaa/main.py line 30 from process import supervisor 5. in kaa/process.py line 182 supervisor = _Supervisor 6. in kaa/process.py line 64 in constructor of _Supervisor : signal.signal(signal.SIGCHLD, self._sigchld_handler) From tonight's investigations, I could get the following backtrace which is where the timer is started and thus the notifier is said to be already started. -- import kaa File /usr/lib/python2.5/site-packages/kaa/__init__.py, line 39, in module from async import TimeoutException, InProgress, InProgressCallback, \ File /usr/lib/python2.5/site-packages/kaa/async.py, line 977, in module import main File /usr/lib/python2.5/site-packages/kaa/main.py, line 50, in module from process import supervisor File /usr/lib/python2.5/site-packages/kaa/process.py, line 182, in module supervisor = _Supervisor() File /usr/lib/python2.5/site-packages/kaa/process.py, line 79, in __init__ libc=ctypes.util.find_library('c') File /usr/lib/python2.5/ctypes/util.py, line 164, in find_library return _findSoname_ldconfig(name) or _get_soname(_findLib_gcc(name)) File /usr/lib/python2.5/ctypes/util.py, line 158, in _findSoname_ldconfig os.popen('LANG=C /sbin/ldconfig -p 2/dev/null').read()) File /usr/lib/python2.5/site-packages/kaa/timer.py, line 96, in newfunc t.start(interval) -- Now, this is in the @timed decorator from kaa.timer and using a dirty print statement, I could get the only decorated function name which is _sigchld_handler . This signal is triggered, because the ldconfig child process terminates. Knowing this, a working fix, as said, is as simple as delaying the signal setting, as shown by the attached patch, which works. Cheers, Alex diff -Nru kaa-base-0.6.0/src/process.py kaa-base-0.6.0.new//src/process.py --- kaa-base-0.6.0/src/process.py 2010-03-25 23:04:04.0 +0100 +++ kaa-base-0.6.0.new//src/process.py 2010-03-25 23:15:37.0 +0100 @@ -61,7 +61,6 @@ def __init__(self): self.processes = {} -signal.signal(signal.SIGCHLD, self._sigchld_handler) # Set SA_RESTART bit for the signal, which restarts any interrupted # system calls -- however, select (at least on Linux) is NOT restarted # for reasons described at: @@ -72,11 +71,15 @@ v = sys.version_info if v[0] = 3 or (v[0] == 2 and v[1] = 6): # Python 2.6+ +signal.signal(signal.SIGCHLD, self._sigchld_handler) signal.siginterrupt(signal.SIGCHLD, False) elif v[0] == 2 and v[1] == 5: # Python 2.5 import ctypes, ctypes.util libc=ctypes.util.find_library('c') +# ctypes.util.find_library() involves a child process, so the +# hanler should be set after the call. +signal.signal(signal.SIGCHLD, self._sigchld_handler) ctypes.CDLL(libc).siginterrupt(signal.SIGCHLD, 0) else: # Python 2.4- is not supported.