nonblocking read of one xml element?

Stefan Behnel stefan_ml at behnel.de
Tue Feb 5 14:44:51 EST 2008


mh at pixar.com wrote:
> I'm parsing a log file that's being written out in
> real time.
> This is part of an event loop, so I want to have some code
> that looks like this:
>
>    when logfile is readable:
>        read one <entry> node, including children
>        but don't try to read past </entry>, so that
>        the read won't block.

Do you have any control over the program that writes the log file? Maybe you
could make it write the log to a pipe or socket instead, which you could then
connect an XML parser to from the Python side (maybe from a thread to avoid
blocking I/O).

Stefan



More information about the Python-list mailing list