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.
Bug#575293: python-kaa-base: integration with twisted does not work anymore
Package: python-kaa-base Version: 0.6.0-4 Severity: normal Hi, Using the following snippet, from the documentation[1], integration with twisted does not work anymore. Maybe this is related to the new twisted version 10. -- # get reactor from twisted.internet import reactor import kaa kaa.main.select_notifier('twisted') # add callbacks to Twisted or kaa # see test/kaa_in_twisted.py in the kaa.base package # run Twisted mainloop reactor.run() -- The following exception is raised : $ python kaa_twisted.py Traceback (most recent call last): File kaa_twisted.py, line 5, in module kaa.main.select_notifier('twisted') File /usr/lib/python2.5/site-packages/kaa/main.py, line 89, in select_notifier return nf_thread.init(module, **options) File /usr/lib/python2.5/site-packages/kaa/nf_thread.py, line 147, in init notifier.init( 'generic', force_internal=True, **options ) File /usr/lib/python2.5/site-packages/kaa/nf_wrapper.py, line 164, in init raise RuntimeError('notifier already initialized') RuntimeError: notifier already initialized Please note that the test supplied in kaa-base (test/kaa_in_twisted.py ) also fails. Feel free to ask for more info. Thanks, Alex [1] http://doc.freevo.org/api/kaa/base/core/mainloop.html#integration-with-other-frameworks -- System Information: Debian Release: squeeze/sid APT prefers unstable APT policy: (500, 'unstable'), (1, 'experimental') Architecture: amd64 (x86_64) Kernel: Linux 2.6.32-4-amd64 (SMP w/2 CPU cores) Locale: LANG=fr_FR.UTF-8, LC_CTYPE=fr_FR.UTF-8 (charmap=UTF-8) Shell: /bin/sh linked to /bin/dash Versions of packages python-kaa-base depends on: ii libc62.10.2-6Embedded GNU C Library: Shared lib ii libglib2.0-0 2.22.4-1The GLib library of C routines ii python 2.5.4-9 An interactive high-level object-o ii python-central 0.6.14+nmu2 register and build utility for Pyt ii python-sqlite1.0.1-7+b1 python interface to SQLite 2 python-kaa-base recommends no packages. python-kaa-base suggests no packages. -- no debconf information -- To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org
Bug#575293: python-kaa-base: integration with twisted does not work anymore
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 --- kaa/process.py 2010-03-24 20:44:55.080934884 +0100 +++ kaa--new/process.py 2010-03-24 17:57:34.0 +0100 @@ -75,10 +75,8 @@ signal.siginterrupt(signal.SIGCHLD, False) elif v[0] == 2 and v[1] == 5: # Python 2.5 -import ctypes -libc=libc.so.6 -if not os.path.exists('/lib/'+libc): #ia64 -libc=libc.so.6.1 +import ctypes, ctypes.util +libc=ctypes.util.find_library('c') ctypes.CDLL(libc).siginterrupt(signal.SIGCHLD, 0) else: # Python 2.4- is not supported. When we import kaa, this code is called and ctypes.util.find_library call popen function which force kaa notifier init. So when we try to select a notifier after the import, an exception is raised because kaa notifier is already initialized. Thanks Mickaël On Wed, Mar 24, 2010 at 8:01 PM, Alexandre Rossi alexandre.ro...@gmail.com wrote: Package: python-kaa-base Version: 0.6.0-4 Severity: normal Hi, Using the following snippet, from the documentation[1], integration with twisted does not work anymore. Maybe this is related to the new twisted version 10. -- # get reactor from twisted.internet import reactor import kaa kaa.main.select_notifier('twisted') # add callbacks to Twisted or kaa # see test/kaa_in_twisted.py in the kaa.base package # run Twisted mainloop reactor.run() -- The following exception is raised : $ python kaa_twisted.py Traceback (most recent call last): File kaa_twisted.py, line 5, in module kaa.main.select_notifier('twisted') File /usr/lib/python2.5/site-packages/kaa/main.py, line 89, in select_notifier return nf_thread.init(module, **options) File /usr/lib/python2.5/site-packages/kaa/nf_thread.py, line 147, in init notifier.init( 'generic', force_internal=True, **options ) File /usr/lib/python2.5/site-packages/kaa/nf_wrapper.py, line 164, in init raise RuntimeError('notifier already initialized') RuntimeError: notifier already initialized Please note that the test supplied in kaa-base (test/kaa_in_twisted.py ) also fails. Feel free to ask for more info. Thanks, Alex [1] http://doc.freevo.org/api/kaa/base/core/mainloop.html#integration-with-other-frameworks -- System Information: Debian Release: squeeze/sid APT prefers unstable APT policy: (500, 'unstable'), (1, 'experimental') Architecture: amd64 (x86_64) Kernel: Linux 2.6.32-4-amd64 (SMP w/2 CPU cores) Locale: LANG=fr_FR.UTF-8, LC_CTYPE=fr_FR.UTF-8 (charmap=UTF-8) Shell: /bin/sh linked to /bin/dash Versions of packages python-kaa-base depends on: ii libc6 2.10.2-6 Embedded GNU C Library: Shared lib ii libglib2.0-0 2.22.4-1 The GLib library of C routines ii python 2.5.4-9 An interactive high-level object-o ii python-central 0.6.14+nmu2 register and build utility for Pyt ii python-sqlite 1.0.1-7+b1 python interface to SQLite 2 python-kaa-base recommends no packages. python-kaa-base suggests no packages. -- no debconf information -- To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org