Unusual minidom behaviour: Part Deux

Aahz Maruch aahz at panix.com
Sat Jul 28 19:52:14 EDT 2001


In article <O4Y77.12077$Up.356569 at sea-read.news.verio.net>,
Victor Bazarov <vAbazarov at dAnai.com> wrote:
>"Guido van Rossum" <guido at python.org> wrote...
>>
>> Victor, we don't have enough information.  Are you using Jython, or
>> are you somehow invoking C-Python from Java?  Can you reproduce the
>> problem in a self-contained example program?
>
>I am not using Jython.  I am running a regular one (if it's called
>C-Python, I didn't know) from Java using Runtime.exec("python
> something.py").  Its version is 2.0 (at least that's what it
>reports when run with -V).

Python is referred to as CPython when it's not clear what version is
being talked about.  This is because Python has been implemented in two
different languages: C and Java (well, some others, too, but those are
the primary ones and the only relevant ones here).  The Java
implementation is referred to as Jython (formerly JPython).

What OS are you using?  Which JVM?

>In order to write a test program I have to know what to try to
>reproduce.  Should it itself be multi-threaded?  How complex should
>it be?  If I don't get the same result, does it mean the problem is
>in my Java program or is it just a coincidence?  (as I wrote before,
>it does not happen if I run Java program under the debugger instead
>of simply executing it)  You see, it would probably take me as long
>to create a "self-contained" example as it did to create the system
>in its current state.

You've got a complex problem here, probably resulting from a multi-way
interaction between Python, Java, and the OS.  You're going to get little
help from us unless you can pare down the problem.

>One of my colleagues suggested wrapping the call to minidom.parse
>in a critical section (locking something before, unlocking after),
>another hint came from you: let the main program sleep after fork.
>At this point I frankly care only about one thing: to prevent it
>from happening.

That's one way.  I second Paul's suggestion that you instead do the
import before you spin off any threads.  Note that the problem in the
other thread you're referring to was *Python* doing a fork, not Python
executing in the forked process.

I think your best bet is likely to be switching to Jython instead of
trying to run CPython through a system call.  That way, your Python
program will have full access to Java's capabilities, and you'll have
better cross-platform portability.  If you stick with CPython, I suggest
upgrading to Python 2.1.1; IIRC, there were some thread bugs fixed
post-2.0.
-- 
                      --- Aahz  <*>  (Copyright 2001 by aahz at pobox.com)

Hugs and backrubs -- I break Rule 6                 http://www.rahul.net/aahz/
Androgynous poly kinky vanilla queer het Pythonista   

Fortune cookie: Watch your relations with other people carefully, be reserved.



More information about the Python-list mailing list