diff -r ab75d9ba107f asyncio/unix_events.py --- a/asyncio/unix_events.py Wed Nov 05 15:30:16 2014 +0100 +++ b/asyncio/unix_events.py Tue Nov 11 00:30:19 2014 +0100 @@ -13,6 +13,7 @@ from . import base_events from . import base_subprocess from . import constants +from . import coroutines from . import events from . import selector_events from . import selectors @@ -66,6 +67,8 @@ Raise ValueError if the signal number is invalid or uncatchable. Raise RuntimeError if there is a problem setting up the handler. """ + if coroutines.iscoroutinefunction(callback): + raise TypeError("coroutines cannot be used with call_soon()") self._check_signal(sig) try: # set_wakeup_fd() raises ValueError if this is not the diff -r ab75d9ba107f tests/test_unix_events.py --- a/tests/test_unix_events.py Wed Nov 05 15:30:16 2014 +0100 +++ b/tests/test_unix_events.py Tue Nov 11 00:30:19 2014 +0100 @@ -64,6 +64,18 @@ signal.SIGINT, lambda: True) @mock.patch('asyncio.unix_events.signal') + def test_add_signal_handler_coroutine_error(self, m_signal): + + @asyncio.coroutine + def simple_coroutine(): + yield from [] + + self.assertRaises( + TypeError, + self.loop.add_signal_handler, + signal.SIGINT, simple_coroutine) + + @mock.patch('asyncio.unix_events.signal') def test_add_signal_handler(self, m_signal): m_signal.NSIG = signal.NSIG