Beispiel #1
0
 def test_gc_closes(self):
     sock = xcm.server(TEST_ADDRS[0])
     del sock
     gc.collect()
     # getting EADDRINUSE in case socket is not closed
     sock = xcm.server(TEST_ADDRS[0])
     del sock
Beispiel #2
0
 def test_max_fd_exceeded(self):
     sockets = []
     # the assumption is that we will run out of fds fairly quickly
     try:
         while True:
             sockets.append(xcm.server("ux:py-xcmtest-%d" % len(sockets)))
     except xcm.error as e:
         self.assertEqual(e.errno, errno.EMFILE)
     for s in sockets:
         s.close()
Beispiel #3
0
    def test_server_attr(self):
        for addr in TEST_ADDRS:
            sock = xcm.server(addr)

            self.assertEqual(sock.get_attr("xcm.type"), "server")

            sock.set_attr("xcm.blocking", False)
            self.assertEqual(sock.get_attr("xcm.blocking"), False)

            with self.assertRaises(FileNotFoundError):
                sock.set_attr("xcm.tcp_keepalive_interval", 99)

            with self.assertRaises(OSError) as cm:
                sock.set_attr("xcm.blocking", 17)
            self.assertEqual(cm.exception.errno, errno.EINVAL)

            sock.finish()
            sock.set_blocking(True)

            sock.close()