A sensible way to manage python threads with mysql