[issue24904] Patch: add timeout to difflib SequenceMatcher ratio() and quick_ratio()

Raymond Hettinger report at bugs.python.org
Fri Aug 21 00:47:20 CEST 2015


Raymond Hettinger added the comment:

In general, it isn't good design to incorporate timeout logic in computation logic.  What would be better is a general purpose, reusable, decoupled tool: run_with_time_limit(some_computation, some_args, time_limit).  Such a tool might be based on separate process that can be timed or killed, it might use signals, or may be based on threading.Timer.

I did a quick look around the net.  Timeouts on diff APIs aren't common (i.e GNU diff doesn't have a timeout) but there are a couple of precedents (you aren't the first to have had concerns about the running time for unfavorable inputs).

----------
nosy: +rhettinger

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue24904>
_______________________________________


More information about the Python-bugs-list mailing list