I found an example where calculating HtmlDiff in admin.py::final_review() went into an infinite loop and eventually caused the apache process to time out. In the case that caused the error, it was trying to compare crypto.bib from cryptobib with another small file of the same name, and it ran out of RAM. There is apparently a known problem in HtmlDiff. The solution is not obvious, but I can think of several approaches:
- give up on calculating diffs. This would be unfortunate.
- only calculate diffs when the files are both small. This has the unfortunate requirement to
stat() every file, but would be safer.
- only calculate diffs when the files are "relatively close in size". I'm not sure what that would be.
- use a second process to timeout the calculation of HtmlDiff. See https://medium.com/@chaoren/how-to-timeout-in-python-726002bf2291 for a way to do this. This seems clumsy but would probably be safe.
I found an example where calculating HtmlDiff in
admin.py::final_review()went into an infinite loop and eventually caused the apache process to time out. In the case that caused the error, it was trying to comparecrypto.bibfrom cryptobib with another small file of the same name, and it ran out of RAM. There is apparently a known problem in HtmlDiff. The solution is not obvious, but I can think of several approaches:stat()every file, but would be safer.