Esempio n. 1
0
 def _get_socket(self):
     self.log.debug("connecting")
     try:
         sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
         sock.settimeout(self.socket_timeout)
         sock.connect(self.address)
         return sock
     except socket.error, e:
         raise expected(SocketError(_socket_error_message(self.address, e)))
Esempio n. 2
0
 def _get_socket(self):
     self.log.debug("connecting")
     try:
         sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
         sock.settimeout(self.socket_timeout)
         sock.connect(self.address)
         return sock
     except socket.error, e:
         raise expected(SocketError(_socket_error_message(self.address, e)))
Esempio n. 3
0
            return input
        assert_raises(GotSleep, run)

    @parameterized([
        ("keyboard interrupt", KeyboardInterrupt()),
        ("system exit", SystemExit()),
        ("greenlet exit", GreenletExit()),
    ])
    def test_expected_errors(self, name, exception):
        @runloop(log)
        def run():
            raise exception
        assert_raises(type(exception), run)

    @parameterized([
        ("expected exc", expected(Exception("expected exception"))),
        ("unexpected exc", Exception("unexpected exception")),
        ("gevent.Timeout", gevent.Timeout()),
    ])
    def test_restart_on_exception(self, name, exception):
        @runloop(log, sleep=GotSleep.mock())
        def run():
            raise exception
        assert_raises(GotSleep, run)


class TestAPIEdge(XXXTestBase):
    def assert_edge_clean(self, edge):
        assert_equal(edge._call_semaphore.counter,
                     edge.max_concurrent_calls)
Esempio n. 4
0
    def test_normal_return(self):
        @runloop(log, sleep=GotSleep.mock())
        def run(input):
            return input

        assert_raises(GotSleep, run)

    def test_greenlet_exit(self):
        @runloop(log)
        def run():
            raise GreenletExit()

        assert_raises(GreenletExit, run)

    @parameterized([
        expected(Exception("expected exception")),
        Exception("unexpected exception"),
    ])
    def test_restart_on_exception(self, exception):
        @runloop(log, sleep=GotSleep.mock())
        def run():
            raise exception

        assert_raises(GotSleep, run)


class TestAPIEdge(XXXTestBase):
    def assert_edge_clean(self, edge):
        assert_equal(edge._call_semaphore.counter, edge.max_concurrent_calls)

    def test_normal_call(self):