xml.minidom and threads

Uche Ogbuji uche at ogbuji.net
Sun Mar 14 23:15:39 EST 2004


sunilmovva at hotmail.com (Sunil Movva) wrote in message news:<9106c987.0403120759.6b1df015 at posting.google.com>...
> I have an application that uses xml to communicate between threads.
> One of the threads in my app creates an xml message and sends it to a
> second thread. This second thread parses the message and creates a new
> xml message copying most part of the first message and sends it to a
> third thread. The second thread was able to parse the message, while
> the third thread is not able to parse the message that it received. I
> am using minidom implementation of DOM to parse the messages. I am not
> validating the messages.
> So, I wrote this out to a file from the third thread and am able to
> parse this from a stand alone non-threaded app.
> I thought it might be an encoding issue, so I converted to utf-8 and
> it still does not parse it.
> 
> The error message I get is here...
>   File "KQMLMessage.py", line 224, in CreateMessage
>     domDoc = xml.dom.minidom.parseString(message)
>   File "//usr/lib/python2.2/xml/dom/minidom.py", line 967, in
> parseString
>     return _doparse(pulldom.parseString, args, kwargs)
>   File "//usr/lib/python2.2/xml/dom/minidom.py", line 954, in _doparse
>     toktype, rootNode = events.getEvent()
>   File "//usr/lib/python2.2/xml/dom/pulldom.py", line 255, in getEvent
>     self.parser.feed(buf)
>   File "//usr/lib/python2.2/xml/sax/expatreader.py", line 149, in feed
>     self._err_handler.fatalError(exc)
>   File "//usr/lib/python2.2/xml/sax/handler.py", line 38, in
> fatalError
>     raise exception
> SAXParseException: <unknown>:1:1: not well-formed (invalid token)
> 
> So, I came to suspect if xml.minidom module is thread-safe. 
> Any suggestions or comments are welcome.

I agree this sounds as if minidom isn't thread safe.  If so the
fastest way to get this fixed is to come up with a simple test case
and post a bug to:

http://sourceforge.net/tracker/?group_id=6473&atid=106473

--Uche



More information about the Python-list mailing list