edelight/kitchen — pull request #69 by sharkerz (2012-10-26 13:30:21+00:00)
Title: Timeout graphs

When we want to create an graph image file, we call `pydot` library, which is creating a subprocess for calling `graphviz`.

The problem is that `pydot` is not providing a timeout for that subprocess, so if the graph is huge, the process will be executing a huge amount of time.

As it is a web application, several clients can request a graph, so a new subprocess is created and we can have several subprocess using a tremendous amount of resources without noticing it (because the client will be sick of waiting and he would have closed the browser).

Proposed solution:
* A new class `KitchenDot` is inheriting from `pydot.Dot`, setting the Popen object as an attribute of the class, so it can be killed from "outside".
* A custom Thread called `GraphThread` has been created, wrapping the pydot call (and so on the graphviz one). The `join` method is modified for returning the result data, and the `kill` method is created for killing the dot (graphviz) subprocess.