コード例 #1
0
 def test_close_on_error(self):
     port = find_unused_port()
     tr1, pr1 = self.loop.run_until_complete(
         aiozmq.create_zmq_connection(
             lambda: Protocol(self.loop),
             zmq.REQ,
             bind="tcp://127.0.0.1:{}".format(port),
         )
     )
     handler = mock.Mock()
     self.loop.set_exception_handler(handler)
     sock = tr1.get_extra_info("zmq_socket")
     sock.close()
     tr1.write([b"data"])
     self.assertTrue(tr1._closing)
     handler.assert_called_with(
         self.loop,
         {
             "protocol": pr1,
             "exception": mock.ANY,
             "transport": tr1,
             "message": "Fatal write error on zmq socket transport",
         },
     )
     # expecting 'Socket operation on non-socket'
     if sys.platform == "darwin":
         errno = 38
     else:
         errno = 88
     check_errno(errno, handler.call_args[0][1]["exception"])
コード例 #2
0
 def test_close_on_error(self):
     port = find_unused_port()
     tr1, pr1 = self.loop.run_until_complete(
         aiozmq.create_zmq_connection(
             lambda: Protocol(self.loop),
             zmq.REQ,
             bind='tcp://127.0.0.1:{}'.format(port),
             loop=self.loop))
     handler = mock.Mock()
     self.loop.set_exception_handler(handler)
     sock = tr1.get_extra_info('zmq_socket')
     sock.close()
     tr1.write([b'data'])
     self.assertTrue(tr1._closing)
     handler.assert_called_with(
         self.loop, {
             'protocol': pr1,
             'exception': mock.ANY,
             'transport': tr1,
             'message': 'Fatal write error on zmq socket transport'
         })
     # expecting 'Socket operation on non-socket'
     if sys.platform == 'darwin':
         errno = 38
     else:
         errno = 88
     check_errno(errno, handler.call_args[0][1]['exception'])
コード例 #3
0
ファイル: zmq_events_test.py プロジェクト: TadLeonard/aiozmq
 def test_close_on_error(self):
     port = find_unused_port()
     tr1, pr1 = self.loop.run_until_complete(aiozmq.create_zmq_connection(
         lambda: Protocol(self.loop),
         zmq.REQ,
         bind='tcp://127.0.0.1:{}'.format(port),
         loop=self.loop))
     handler = mock.Mock()
     self.loop.set_exception_handler(handler)
     sock = tr1.get_extra_info('zmq_socket')
     sock.close()
     tr1.write([b'data'])
     self.assertTrue(tr1._closing)
     handler.assert_called_with(
         self.loop,
         {'protocol': pr1,
          'exception': mock.ANY,
          'transport': tr1,
          'message': 'Fatal write error on zmq socket transport'})
     # expecting 'Socket operation on non-socket'
     if sys.platform == 'darwin':
         errno = 38
     else:
         errno = 88
     check_errno(errno, handler.call_args[0][1]['exception'])
コード例 #4
0
ファイル: transport_test.py プロジェクト: wabu/aiozmq
 def test_write_common_error(self):
     self.sock.send_multipart.side_effect = zmq.ZMQError(errno.ENOTSUP)
     self.tr.write((b'a', b'b'))
     self.sock.send_multipart.assert_called_once_with((b'a', b'b'),
                                                      zmq.DONTWAIT)
     self.assertFalse(self.proto.pause_writing.called)
     self.assertFalse(self.tr._buffer)
     self.assertEqual(0, self.tr._buffer_size)
     self.assertNotIn(self.sock, self.loop.writers)
     check_errno(errno.ENOTSUP,
                 self.exc_handler.call_args[0][1]['exception'])
コード例 #5
0
ファイル: transport_test.py プロジェクト: TadLeonard/aiozmq
 def test_write_common_error(self):
     self.sock.send_multipart.side_effect = zmq.ZMQError(errno.ENOTSUP)
     self.tr.write((b'a', b'b'))
     self.sock.send_multipart.assert_called_once_with(
         (b'a', b'b'), zmq.DONTWAIT)
     self.assertFalse(self.proto.pause_writing.called)
     self.assertFalse(self.tr._buffer)
     self.assertEqual(0, self.tr._buffer_size)
     self.assertNotIn(self.sock, self.loop.writers)
     check_errno(errno.ENOTSUP,
                 self.exc_handler.call_args[0][1]['exception'])
コード例 #6
0
ファイル: zmq_stream_test.py プロジェクト: aio-libs/aiozmq
 async def go():
     s1 = await aiozmq.create_zmq_stream(
         zmq.REP, bind="tcp://127.0.0.1:{}".format(port))
     handler = mock.Mock()
     self.loop.set_exception_handler(handler)
     s1.write([b"data"])
     with self.assertRaises(OSError) as ctx:
         await s1.read()
     check_errno(zmq.EFSM, ctx.exception)
     with self.assertRaises(OSError) as ctx2:
         await s1.drain()
     check_errno(zmq.EFSM, ctx2.exception)
コード例 #7
0
ファイル: zmq_stream_test.py プロジェクト: ticosax/aiozmq
 def go():
     s1 = yield from aiozmq.create_zmq_stream(
         zmq.REP,
         bind='tcp://127.0.0.1:{}'.format(port),
         loop=self.loop)
     handler = mock.Mock()
     self.loop.set_exception_handler(handler)
     s1.write([b'data'])
     with self.assertRaises(OSError) as ctx:
         yield from s1.read()
     check_errno(zmq.EFSM, ctx.exception)
     with self.assertRaises(OSError) as ctx2:
         yield from s1.drain()
     check_errno(zmq.EFSM, ctx2.exception)
コード例 #8
0
ファイル: zmq_stream_test.py プロジェクト: TadLeonard/aiozmq
 def go():
     s1 = yield from aiozmq.create_zmq_stream(
         zmq.REP,
         bind='tcp://127.0.0.1:{}'.format(port),
         loop=self.loop)
     handler = mock.Mock()
     self.loop.set_exception_handler(handler)
     s1.write([b'data'])
     with self.assertRaises(OSError) as ctx:
         yield from s1.read()
     check_errno(zmq.EFSM, ctx.exception)
     with self.assertRaises(OSError) as ctx2:
         yield from s1.drain()
     check_errno(zmq.EFSM, ctx2.exception)