'Test that poll() is properly restarted after receiving EINTR error.
Class of an exception raised to signal the error differs in one
implementation of polling mechanism and another.'

@unittest.skipUnless(pika.compat.HAVE_SIGNAL, "This    platform    doesn't    support    posix    signals")
@mock.patch('pika.adapters.select_connection._is_resumable')
def test_eintr(self, is_resumable_mock, is_resumable_raw=pika.adapters.select_connection._is_resumable):

    is_resumable_mock.side_effect = is_resumable_raw
    self.poller = self.ioloop._get_poller()
    sockpair = self.poller._get_interrupt_pair()
    self.addCleanup(sockpair[0].close)
    self.addCleanup(sockpair[1].close)
    self._eintr_read_handler_is_called = False
    self.poller.add_handler(sockpair[0].fileno(), self._eintr_read_handler, READ)
    self.poller.add_timeout(self.TIMEOUT, self._eintr_test_fail)
    original_signal_handler = signal.signal(signal.SIGUSR1, self.signal_handler)
    self.addCleanup(signal.signal, signal.SIGUSR1, original_signal_handler)
    tmr_k = threading.Timer(0.1, (lambda : os.kill(os.getpid(), signal.SIGUSR1)))
    self.addCleanup(tmr_k.cancel)
    tmr_w = threading.Timer(0.2, (lambda : sockpair[1].send(self.MSG_CONTENT)))
    self.addCleanup(tmr_w.cancel)
    tmr_k.start()
    tmr_w.start()
    self.poller.start()
    self.assertTrue(self._eintr_read_handler_is_called)
    if pika.compat.EINTR_IS_EXPOSED:
        self.assertEqual(is_resumable_mock.call_count, 1)
    else:
        self.assertEqual(is_resumable_mock.call_count, 0)
