added a simple timeout mechanism according to http://pguides.net/python-tutorial/python-timeout-a-function/