Sunday, November 15, 2009

tidy crashed on Debian 64bit

I'm was working on a python project that invoked a tidy process. We were using the tidy python wrapper utidylib for that, with this code:
import tidy
tidy_obj = tidy.parseString(html, {})
tidy_outstream = StringIO.StringIO()
tidy_obj.write(tidy_outstream)
tidy_html = tidy_outstream.getvalue()
And it worked fine. Almost.
When  invoked it more frequently, i.e. every few seconds, it sometimes succeeded and sometimes crashed, FOR THE SAME HTML INPUT.
Searching the Internet I found that there is a known issue of tidy crashes on Debian 64 bit machines. Too bad.
Looking for an alternate tool to do the same trick I found another python wrapper for tidy that pretends to solve this issue: pytidylib. And the syntax is simpler:
import tidylib
tidy_html, errs = tidylib.tidy_document(html, {})
And guess what ? tidy process no longer crashes !
And while you are reading this, you may find this list of tidy options useful.
Enjoy tidying :-)

No comments: