I could not reproduce the bug with the first test file I wrote, but a
modified version reproduces the bug reliably for me with python2.4-dbg
from ubuntu edgy x86:

import time, os, thread

def f():
    print "I am thread %d in process %d" % (thread.get_ident(),os.getpid())
    time.sleep(1)

ident = thread.start_new_thread(f, ())
print "started thread %d in process %d" % (ident, os.getpid())
time.sleep(0.5)      # give thread a chance to start

pid = os.fork()
if pid == 0:
    ident = thread.start_new_thread(f, ())
    print "started thread %d in process %d" % (ident, os.getpid())
    time.sleep(0.5)      # give thread a chance to start
    os._exit(0)

os.waitpid(pid, 0)

The output is

    started thread -1210782816 in process 18687
    I am thread -1210782816 in process 18687
    started thread -1210782816 in process 18689
    Fatal Python error: Invalid thread state for this thread
    [5817 refs]

I think the problem has to do with the fact that the child process's
subthread has the same id as the parent process's subthread, so the
thread local storage implementation gets confused.

I will file a bug at bugs.python.org.

Cheers,

Richard.


On 21/12/2007, Sandro Tosi <[EMAIL PROTECTED]> wrote:
> Package: python-all-dbg
> Version: 2.4.4-6
> Severity: normal
>
> Hello,
> while packaging processing (a python module to use processes like
> threads) I've faced a strange error: running tests with python2.{4,5} no
> problem, but using -dbg version an error comes out "Fatal Python error:
> Invalid thread state for this thread".
>
> Richard (upstream author of processing) kindly provided me a small test
> python program to spot the problem (dbg.py attached to this report):
>
> [EMAIL PROTECTED]:~$ python2.4 ~/tmp/dbg.py
> parent sleeping ...
> child sleeping ...
> ... child waking
> child exiting
> ... parent waking
> parent exiting
> [EMAIL PROTECTED]:~$ python2.5 ~/tmp/dbg.py
> parent sleeping ...
> child sleeping ...
> ... parent waking
> ... child waking
> child exiting
> parent exiting
> [EMAIL PROTECTED]:~$ python2.4-dbg ~/tmp/dbg.py
> parent sleeping ...
> Fatal Python error: Invalid thread state for this thread
> ... parent waking
> parent exiting
> [7951 refs]
> [EMAIL PROTECTED]:~$ python2.5-dbg ~/tmp/dbg.py
> parent sleeping ...
> Fatal Python error: Invalid thread state for this thread
> ... parent waking
> parent exiting
> [9809 refs]
>
> The behaviour of python2.{4,5} is the intended one, while with -dbg the error 
> appears.
>
> It could be due to my arch (amd64), an issue on packaging or something deeper 
> in python code.
>
> Thanks,
> Sandro
>
> -- System Information:
> Debian Release: lenny/sid
>   APT prefers unstable
>   APT policy: (500, 'unstable'), (500, 'testing')
> Architecture: amd64 (x86_64)
>
> Kernel: Linux 2.6.22-2-amd64 (SMP w/4 CPU cores)
> Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
> Shell: /bin/sh linked to /bin/bash
>
> Versions of packages python-all-dbg depends on:
> ii  python-all                    2.4.4-6    Package depending on all 
> supported
> ii  python-dbg                    2.4.4-6    Debug Build of the Python 
> Interpre
> ii  python2.4-dbg                 2.4.4-6    Debug Build of the Python 
> Interpre
> ii  python2.5-dbg                 2.5.1-5    Debug Build of the Python 
> Interpre
>
> python-all-dbg recommends no packages.
>
> -- no debconf information
>
>



-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to