コード例 #1
0
ファイル: peers_manager.py プロジェクト: GurovNik/tor
    def run(self):
        while self.is_active:
            read = [peer.socket for peer in self.peers]
            read_list, _, _ = select.select(read, [], [], 1)

            for socket in read_list:
                peer = self.get_peer_by_socket(socket)
                if not peer.healthy:
                    self.remove_peer(peer)
                    continue
                try:
                    payload = self._read_from_socket(socket)
                except:
                    continue

                peer.read_buffer += payload
                for message in peer.get_messages():
                    self._process_new_message(message, peer)
コード例 #2
0
ファイル: peers_manager.py プロジェクト: gallexis/pytorrent
    def run(self):
        while self.is_active:
            read = [p.socket for p in self.peers]
            read_list, _, _ = select.select(read, [], [], 1)

            for socket in read_list:
                peer = self.get_peer_by_socket(socket)
                if peer.to_remove:
                    self.remove_peer(peer)
                    continue

                payload = self._read_from_socket(socket)
                if not payload:
                    self.remove_peer(peer)
                    continue

                peer.read_buffer += payload

                for message in peer.get_messages():
                    self._process_new_message(message, peer)