'Mocks the select.select() call to raise EINTR for first call'

@contextlib.contextmanager
def mocked_select_module(self):

    old_select = select.select
    class MockSelect:
        def __init__(self):
            self.called = 0
        def __call__(self, *args):
            self.called += 1
            if (self.called == 1):
                raise select.error(errno.EINTR, os.strerror(errno.EINTR))
            else:
                return old_select(*args)
    select.select = MockSelect()
    try:
        (yield select.select)
    finally:
        select.select = old_select
