List Info

Thread: fun threading problem




fun threading problem
user name
2006-09-14 07:48:57
On everyones favorite platform (HP-UX), the following code
consistently fails:

###
from thread import start_new_thread, allocate_lock
from time import sleep

def bootstrap():
    from os import fork ; fork()
    allocate_lock().acquire()

start_new_thread(bootstrap, ())
sleep(.1)
###

The error is:
Fatal Python error: Invalid thread state for this thread

This code was whittled down from test_socketserver which
fails in the
same way.  It doesn't matter what value is passed to sleep
as long as
it's greater than 0.  I also tried changing the sleep to a
while 1:
pass and the same problem occurred.  So there isn't a huge
interaction
of APIs, only:  fork, allocate_lock.acquire and
start_new_thread.

HP-UX seems to be more sensitive to various threading
issues.  In
Modules/_test_capimodule.c, I had to make this modification:

Index: Modules/_testcapimodule.c
============================================================
=======
--- Modules/_testcapimodule.c   (revision 51875)
+++ Modules/_testcapimodule.c   (working copy)
 -665,6
+665,9 
        PyThread_acquire_lock(thread_done, 1);  /* wait for
thread to finish */
        Py_END_ALLOW_THREADS

+       /* Release lock we acquired above.  This is required
on HP-UX. */
+       PyThread_release_lock(thread_done);
+
        PyThread_free_lock(thread_done);
        Py_RETURN_NONE;
 }

Without that patch, there would be this error:

sem_destroy: Device busy
sem_init: Device busy
Fatal Python error: UNREF invalid object
ABORT instruction (core dumped)

Anyone have any ideas?

n
_______________________________________________
Python-Dev mailing list
Python-Devpython.org
ht
tp://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: http://mail.python.org/mailman/options/p
ython-dev/nessto%40sharedlog.com
fun threading problem
user name
2006-09-14 14:31:14
On Thu, Sep 14, 2006, Neal Norwitz wrote:
>
> On everyones favorite platform (HP-UX), the following
code
> consistently fails:

Which exact HP-UX?  I remember from my ancient days that
each HP-UX
version completely changes the way threading works -- dunno
whether
that's still true.
-- 
Aahz (aahzpythoncraft.com)           <*>         http://www.pythoncraft.co
m/

"LL YR VWL R BLNG T S"  -- www.nancybuttons.com
_______________________________________________
Python-Dev mailing list
Python-Devpython.org
ht
tp://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: http://mail.python.org/mailman/options/p
ython-dev/nessto%40sharedlog.com
fun threading problem
user name
2006-09-14 14:31:14
On Thu, Sep 14, 2006, Neal Norwitz wrote:
>
> On everyones favorite platform (HP-UX), the following
code
> consistently fails:

Which exact HP-UX?  I remember from my ancient days that
each HP-UX
version completely changes the way threading works -- dunno
whether
that's still true.
-- 
Aahz (aahzpythoncraft.com)           <*>         http://www.pythoncraft.co
m/

"LL YR VWL R BLNG T S"  -- www.nancybuttons.com
_______________________________________________
Python-Dev mailing list
Python-Devpython.org
ht
tp://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: http://mail.python.org/mailman/options/p
ython-dev/nessto%40sharedlog.com
fun threading problem
user name
2006-09-15 05:51:54
On 9/14/06, Aahz <aahzpythoncraft.com> wrote:
> On Thu, Sep 14, 2006, Neal Norwitz wrote:
> >
> > On everyones favorite platform (HP-UX), the
following code
> > consistently fails:
>
> Which exact HP-UX?  I remember from my ancient days
that each HP-UX
> version completely changes the way threading works --
dunno whether
> that's still true.

 HP-UX 11i v2 on PA-RISC

td191 on http://www.
testdrive.hp.com/current.shtml
_______________________________________________
Python-Dev mailing list
Python-Devpython.org
ht
tp://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: http://mail.python.org/mailman/options/p
ython-dev/nessto%40sharedlog.com
[1-4]

about | contact  Other archives ( Real Estate discussion Medical topics )