Unusual minidom behaviour: Part Deux

Martin von Loewis loewis at informatik.hu-berlin.de
Fri Jul 27 09:43:08 EDT 2001


"Victor Bazarov" <vAbazarov at dAnai.com> writes:

> The system that tries to use some XML files is written in Python
> and is being run from under a Java application.  In the system
> something (that looks like a deadlock) happens when two threads
> both need to parse (each its own) XML file.  

When you say "thread" here, do you mean "Java thread" or "Python
thread"? I assume you mean "Java thread", since you did not indicate
at all that you are using threads in your Python application.

Note that when you call Java's Runtime.exec, you create a new
operating system process. So when two Java threads simultaneously
invoke Runtime.exec, you end up with two operating system processes,
each running a separate Python interpreter - not with a single Python
interpreter running two threads.

Can you please confirm that this is the situation you are confronted
with?

> Both call 'parse' from 'minidom' package, which leads to an attempt
> to __import__ the xml.sax.expatreader.

Assuming that the two Python interpreters run single-threaded, ignore
any Python thread issues - they won't be relevant.

What might be relevant is that two Python interpreters might be
simultaneously create the same output files; I don't know enough about
your application to know whether this might happen. I also don't know
at the moment how Python would deal with a case where two Python
interpreters generate the same byte code file simultaneously.

> The questions I have are: has anyone else seen anything of sorts
> and where should I look to try to find _why_ this is happening?

No, I haven't seen this. I doubt it has to do with your Python code,
so you should look into the Java part.

Regards,
Martin



More information about the Python-list mailing list