{"action":"closed","issue":{"url":"https://api.github.com/repos/datafolklabs/cement/issues/342","repository_url":"https://api.github.com/repos/datafolklabs/cement","labels_url":"https://api.github.com/repos/datafolklabs/cement/issues/342/labels{/name}","comments_url":"https://api.github.com/repos/datafolklabs/cement/issues/342/comments","events_url":"https://api.github.com/repos/datafolklabs/cement/issues/342/events","html_url":"https://github.com/datafolklabs/cement/issues/342","id":134915181,"number":342,"title":"Add Alarm/Timeout Support","user":{"login":"derks","id":130503,"avatar_url":"https://avatars.githubusercontent.com/u/130503?v=3","gravatar_id":"","url":"https://api.github.com/users/derks","html_url":"https://github.com/derks","followers_url":"https://api.github.com/users/derks/followers","following_url":"https://api.github.com/users/derks/following{/other_user}","gists_url":"https://api.github.com/users/derks/gists{/gist_id}","starred_url":"https://api.github.com/users/derks/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/derks/subscriptions","organizations_url":"https://api.github.com/users/derks/orgs","repos_url":"https://api.github.com/users/derks/repos","events_url":"https://api.github.com/users/derks/events{/privacy}","received_events_url":"https://api.github.com/users/derks/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/datafolklabs/cement/labels/dev/2.7.x","name":"dev/2.7.x","color":"DDDDDD"},{"url":"https://api.github.com/repos/datafolklabs/cement/labels/feature","name":"feature","color":"02e10c"}],"state":"closed","locked":false,"assignee":{"login":"derks","id":130503,"avatar_url":"https://avatars.githubusercontent.com/u/130503?v=3","gravatar_id":"","url":"https://api.github.com/users/derks","html_url":"https://github.com/derks","followers_url":"https://api.github.com/users/derks/followers","following_url":"https://api.github.com/users/derks/following{/other_user}","gists_url":"https://api.github.com/users/derks/gists{/gist_id}","starred_url":"https://api.github.com/users/derks/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/derks/subscriptions","organizations_url":"https://api.github.com/users/derks/orgs","repos_url":"https://api.github.com/users/derks/repos","events_url":"https://api.github.com/users/derks/events{/privacy}","received_events_url":"https://api.github.com/users/derks/received_events","type":"User","site_admin":false},"milestone":{"url":"https://api.github.com/repos/datafolklabs/cement/milestones/24","html_url":"https://github.com/datafolklabs/cement/milestones/2.8.0%20Stable","labels_url":"https://api.github.com/repos/datafolklabs/cement/milestones/24/labels","id":1108766,"number":24,"title":"2.8.0 Stable","description":"","creator":{"login":"derks","id":130503,"avatar_url":"https://avatars.githubusercontent.com/u/130503?v=3","gravatar_id":"","url":"https://api.github.com/users/derks","html_url":"https://github.com/derks","followers_url":"https://api.github.com/users/derks/followers","following_url":"https://api.github.com/users/derks/following{/other_user}","gists_url":"https://api.github.com/users/derks/gists{/gist_id}","starred_url":"https://api.github.com/users/derks/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/derks/subscriptions","organizations_url":"https://api.github.com/users/derks/orgs","repos_url":"https://api.github.com/users/derks/repos","events_url":"https://api.github.com/users/derks/events{/privacy}","received_events_url":"https://api.github.com/users/derks/received_events","type":"User","site_admin":false},"open_issues":6,"closed_issues":21,"state":"open","created_at":"2015-05-13T15:06:16Z","updated_at":"2016-02-22T21:21:10Z","due_on":null,"closed_at":null},"comments":0,"created_at":"2016-02-19T16:55:21Z","updated_at":"2016-02-22T21:21:10Z","closed_at":"2016-02-22T21:21:10Z","body":"Useful to handle script timeouts using `signal.alarm` but might be a wider usecase to simply support timing out any operation within the app.  Something like:\r\n\r\n```python\r\nwith CementApp('myapp') as app:\r\n    # fail after 5 minutes (300 seconds)\r\n    app.timer.set(300)\r\n    app.run()\r\n    app.timer.stop()\r\n```\r\n\r\n\r\nWrapping the functionality of:\r\n\r\n```python\r\nimport signal\r\n\r\ndef timeout_handler(signum, frame):\r\n    Raise Exception('Operation Timed Out')\r\n\r\nwith CementApp('myapp') as app:\r\n    # fail after 5 minutes (300 seconds)\r\n    signal.signal(signal.SIGALRM, timeout_handler)\r\n    signal.alarm(300)\r\n\r\n    app.run()\r\n\r\n    signal.alarm(0)\r\n```\r\n\r\nNote that handling the signal is already possible with the builtin `CementApp` signal handling mechanisms.  Also note that `signal.alarm` is only available on Unix/Linux."}}