def test_already_connected(self): s = concurrent.connect(self.s.local_addr()) s.send("apa") wait_for(lambda: "apa" in self.s.connections) s1 = concurrent.connect(self.s.local_addr()) s1.send("apa") assert_equal(s1.recv(1024), "")
def close(self): if self._sock: sock = self._sock self._sock = None sname = sock.getsockname() sock.close() # Connect to break possibly hung accept()-call try: concurrent.connect(sname) except socket.error: pass self.wait()
def test_sessionTermination(self): s = concurrent.connect(self.s.local_addr()) s.send("apa") wait_for(lambda: "apa" in self.s.connections) s.shutdown(socket.SHUT_WR) s.close() wait_for(lambda: "apa" not in self.s.connections)
def _connect(self, tgt): m = self.HOST_PORT_RE.match(tgt) if m: tgt = (m.group(1), int(m.group(2))) if isinstance(tgt, tuple): family = socket.AF_INET else: family = socket.AF_UNIX self._socket = concurrent.connect(tgt, family)
def socket_pair(): s = concurrent.socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.bind(("", 0)) try: s.listen(1) t = concurrent.spawn(s.accept) c1 = concurrent.connect(s.getsockname()) c2, _ = t.wait() return c1, c2 except: return None, None finally: s.close()
def _connect(addr): try: return addr, concurrent.connect(addr) except Exception: return addr, None
def connect(self, name="Syncer2"): db = DB(":memory:") s = concurrent.connect(self.s.local_addr()) return SyncConnection(db, name, s, None)
def test_connected(self): s = concurrent.connect(self.s.local_addr()) s.send("apa") wait_for(lambda: "apa" in self.s.connections) s.close()
def test_connect(self): s = concurrent.connect(self.s.local_addr()) assert_is_not_none(s) s.send("apa") assert_equal(s.recv(1024), "apa") s.close()