{"action":"created","issue":{"url":"https://api.github.com/repos/itamarst/crochet/issues/75","labels_url":"https://api.github.com/repos/itamarst/crochet/issues/75/labels{/name}","comments_url":"https://api.github.com/repos/itamarst/crochet/issues/75/comments","events_url":"https://api.github.com/repos/itamarst/crochet/issues/75/events","html_url":"https://github.com/itamarst/crochet/issues/75","id":56796983,"number":75,"title":"wait_for and run_in_reactor swallow exceptions","user":{"login":"hynek","id":41240,"avatar_url":"https://avatars.githubusercontent.com/u/41240?v=3","gravatar_id":"","url":"https://api.github.com/users/hynek","html_url":"https://github.com/hynek","followers_url":"https://api.github.com/users/hynek/followers","following_url":"https://api.github.com/users/hynek/following{/other_user}","gists_url":"https://api.github.com/users/hynek/gists{/gist_id}","starred_url":"https://api.github.com/users/hynek/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hynek/subscriptions","organizations_url":"https://api.github.com/users/hynek/orgs","repos_url":"https://api.github.com/users/hynek/repos","events_url":"https://api.github.com/users/hynek/events{/privacy}","received_events_url":"https://api.github.com/users/hynek/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/itamarst/crochet/labels/bug","name":"bug","color":"fc2929"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":11,"created_at":"2015-02-06T10:45:31Z","updated_at":"2015-06-12T11:20:59Z","closed_at":null,"body":"Consider the following code:\r\n\r\n```python\r\nfrom __future__ import absolute_import, division, print_function\r\n\r\nfrom crochet import no_setup, wait_for, run_in_reactor\r\n\r\nno_setup()\r\n\r\nfrom twisted.trial import unittest as unittest_twisted\r\nimport unittest as unittest_stdlib\r\n\r\n\r\nclass C(object):\r\n    @wait_for(1)\r\n    def wait_for(self):\r\n        raise Exception\r\n\r\n    @run_in_reactor\r\n    def run_in_reactor(self):\r\n        raise Exception\r\n\r\n    def vanilla(self):\r\n        raise Exception\r\n\r\n\r\nclass TestStdLib(unittest_stdlib.TestCase):\r\n    def test_wait_for(self):\r\n        C().wait_for()\r\n\r\n    def test_run_in_reactor(self):\r\n        C().run_in_reactor()\r\n\r\n    def test_vanilla(self):\r\n        C().vanilla()\r\n\r\n\r\nclass TestTwistedDefault(unittest_twisted.TestCase):\r\n    def test_wait_for(self):\r\n        C().wait_for()\r\n\r\n    def test_run_in_reactor(self):\r\n        C().run_in_reactor()\r\n\r\n    def test_vanilla(self):\r\n        C().vanilla()\r\n\r\n\r\nclass TestTwistedSync(unittest_twisted.SynchronousTestCase):\r\n    def test_wait_for(self):\r\n        C().wait_for()\r\n\r\n    def test_run_in_reactor(self):\r\n        C().run_in_reactor()\r\n\r\n    def test_vanilla(self):\r\n        C().vanilla()\r\n```\r\n\r\nThe output of running it with trial on Python 2.7.8 (OS X) is as following:\r\n\r\n```\r\ntest_t\r\n  TestStdLib\r\n    test_run_in_reactor ...                                                [OK]\r\n    test_vanilla ...                                                    [ERROR]\r\n    test_wait_for ...                                                   [ERROR]\r\n  TestTwistedDefault\r\n    test_run_in_reactor ...                                             [ERROR]\r\n                                            [ERROR]\r\n    test_vanilla ...                                                    [ERROR]\r\n    test_wait_for ...                                                   [ERROR]\r\n                                                  [ERROR]\r\n  TestTwistedSync\r\n    test_run_in_reactor ...                                                [OK]\r\n    test_vanilla ...                                                    [ERROR]\r\n    test_wait_for ...                                                   [ERROR]\r\n\r\n===============================================================================\r\n[ERROR]\r\nTraceback (most recent call last):\r\n  File \"/Users/hynek/.pyenv/versions/2.7.8/lib/python2.7/unittest/case.py\", line 329, in run\r\n    testMethod()\r\n  File \"/Users/hynek/Projects/ssce/test_t.py\", line 32, in test_vanilla\r\n    C().vanilla()\r\n  File \"/Users/hynek/Projects/ssce/test_t.py\", line 21, in vanilla\r\n    raise Exception\r\nexceptions.Exception: \r\n\r\ntest_t.TestStdLib.test_vanilla\r\n===============================================================================\r\n[ERROR]\r\nTraceback (most recent call last):\r\n  File \"/Users/hynek/.pyenv/versions/2.7.8/lib/python2.7/unittest/case.py\", line 329, in run\r\n    testMethod()\r\n  File \"/Users/hynek/Projects/ssce/test_t.py\", line 26, in test_wait_for\r\n    C().wait_for()\r\n  File \"/Users/hynek/.virtualenvs/sscce/lib/python2.7/site-packages/crochet/_eventloop.py\", line 461, in wrapper\r\n    return eventual_result.wait(timeout)\r\n  File \"/Users/hynek/.virtualenvs/sscce/lib/python2.7/site-packages/crochet/_eventloop.py\", line 229, in wait\r\n    result = self._result(timeout)\r\n  File \"/Users/hynek/.virtualenvs/sscce/lib/python2.7/site-packages/crochet/_eventloop.py\", line 193, in _result\r\n    raise TimeoutError()\r\ncrochet._eventloop.TimeoutError: \r\n\r\ntest_t.TestStdLib.test_wait_for\r\n===============================================================================\r\n[ERROR]\r\nTraceback (most recent call last):\r\n  File \"/Users/hynek/.virtualenvs/sscce/lib/python2.7/site-packages/twisted/internet/defer.py\", line 140, in maybeDeferred\r\n    result = f(*args, **kw)\r\n  File \"/Users/hynek/Projects/ssce/test_t.py\", line 18, in run_in_reactor\r\n    raise Exception\r\nexceptions.Exception: \r\n\r\ntest_t.TestTwistedDefault.test_run_in_reactor\r\ntest_t.TestTwistedDefault.test_run_in_reactor\r\n===============================================================================\r\n[ERROR]\r\nTraceback (most recent call last):\r\n  File \"/Users/hynek/Projects/ssce/test_t.py\", line 43, in test_vanilla\r\n    C().vanilla()\r\n  File \"/Users/hynek/Projects/ssce/test_t.py\", line 21, in vanilla\r\n    raise Exception\r\nexceptions.Exception: \r\n\r\ntest_t.TestTwistedDefault.test_vanilla\r\n===============================================================================\r\n[ERROR]\r\nTraceback (most recent call last):\r\n  File \"/Users/hynek/Projects/ssce/test_t.py\", line 37, in test_wait_for\r\n    C().wait_for()\r\n  File \"/Users/hynek/.virtualenvs/sscce/lib/python2.7/site-packages/crochet/_eventloop.py\", line 461, in wrapper\r\n    return eventual_result.wait(timeout)\r\n  File \"/Users/hynek/.virtualenvs/sscce/lib/python2.7/site-packages/crochet/_eventloop.py\", line 229, in wait\r\n    result = self._result(timeout)\r\n  File \"/Users/hynek/.virtualenvs/sscce/lib/python2.7/site-packages/crochet/_eventloop.py\", line 193, in _result\r\n    raise TimeoutError()\r\ncrochet._eventloop.TimeoutError: \r\n\r\ntest_t.TestTwistedDefault.test_wait_for\r\n===============================================================================\r\n[ERROR]\r\nTraceback (most recent call last):\r\n  File \"/Users/hynek/.virtualenvs/sscce/lib/python2.7/site-packages/twisted/internet/defer.py\", line 140, in maybeDeferred\r\n    result = f(*args, **kw)\r\n  File \"/Users/hynek/.virtualenvs/sscce/lib/python2.7/site-packages/crochet/_eventloop.py\", line 458, in run\r\n    return function(*args, **kwargs)\r\n  File \"/Users/hynek/Projects/ssce/test_t.py\", line 14, in wait_for\r\n    raise Exception\r\nexceptions.Exception: \r\n\r\ntest_t.TestTwistedDefault.test_wait_for\r\n===============================================================================\r\n[ERROR]\r\nTraceback (most recent call last):\r\n  File \"/Users/hynek/Projects/ssce/test_t.py\", line 54, in test_vanilla\r\n    C().vanilla()\r\n  File \"/Users/hynek/Projects/ssce/test_t.py\", line 21, in vanilla\r\n    raise Exception\r\nexceptions.Exception: \r\n\r\ntest_t.TestTwistedSync.test_vanilla\r\n===============================================================================\r\n[ERROR]\r\nTraceback (most recent call last):\r\n  File \"/Users/hynek/Projects/ssce/test_t.py\", line 48, in test_wait_for\r\n    C().wait_for()\r\n  File \"/Users/hynek/.virtualenvs/sscce/lib/python2.7/site-packages/crochet/_eventloop.py\", line 461, in wrapper\r\n    return eventual_result.wait(timeout)\r\n  File \"/Users/hynek/.virtualenvs/sscce/lib/python2.7/site-packages/crochet/_eventloop.py\", line 229, in wait\r\n    result = self._result(timeout)\r\n  File \"/Users/hynek/.virtualenvs/sscce/lib/python2.7/site-packages/crochet/_eventloop.py\", line 193, in _result\r\n    raise TimeoutError()\r\ncrochet._eventloop.TimeoutError: \r\n\r\ntest_t.TestTwistedSync.test_wait_for\r\n-------------------------------------------------------------------------------\r\nRan 9 tests in 3.020s\r\n\r\nFAILED (errors=9, successes=2)\r\n```\r\n\r\nThe output is the same on pypy.\r\n\r\nI hope this is helpful."},"comment":{"url":"https://api.github.com/repos/itamarst/crochet/issues/comments/111456978","html_url":"https://github.com/itamarst/crochet/issues/75#issuecomment-111456978","issue_url":"https://api.github.com/repos/itamarst/crochet/issues/75","id":111456978,"user":{"login":"dpnova","id":229943,"avatar_url":"https://avatars.githubusercontent.com/u/229943?v=3","gravatar_id":"","url":"https://api.github.com/users/dpnova","html_url":"https://github.com/dpnova","followers_url":"https://api.github.com/users/dpnova/followers","following_url":"https://api.github.com/users/dpnova/following{/other_user}","gists_url":"https://api.github.com/users/dpnova/gists{/gist_id}","starred_url":"https://api.github.com/users/dpnova/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dpnova/subscriptions","organizations_url":"https://api.github.com/users/dpnova/orgs","repos_url":"https://api.github.com/users/dpnova/repos","events_url":"https://api.github.com/users/dpnova/events{/privacy}","received_events_url":"https://api.github.com/users/dpnova/received_events","type":"User","site_admin":false},"created_at":"2015-06-12T11:20:59Z","updated_at":"2015-06-12T11:20:59Z","body":"Actually @itamarst I totally misread the doc about wrapped_function - that's working as expected with `no_setup()` now!\r\n\r\nBut, duly noted about not using the async test case.. thanks :)"}}