İstemci sunucudan ayrıldıktan sonra sunucunun ayrılan istemciyle ilgili işlem yapmaya devam etmesini nasıl engellerim?

Allah allah çok ilginç.

Malesef. Bugünlük bu kadar, yarın vakit olursa devam edelim. Kusura bakmayın biraz uykuluyum da :slight_smile:

Kolay gelsin.

Estağfurullah, ne kusuru, ilginiz için çok teşekkür ederim. İyi geceler. :slight_smile:

Kodları değiştirdikten sonra Windows’ta log dosyasına aşağıdaki ifadeler yazdırıldı:

- DEBUG - 01.10.2019 13:44:54 - Using selector: SelectSelector
- INFO - 01.10.2019 13:44:54 - Server started on ('127.0.0.1', 12345)
- INFO - 01.10.2019 13:45:04 - ('127.0.0.1', 49947) is connected.
- INFO - 01.10.2019 13:45:13 - ('127.0.0.1', 49950) is connected.
- DEBUG - 01.10.2019 13:45:14 - ('127.0.0.1', 49950): veli: selam
- DEBUG - 01.10.2019 13:45:14 - ('127.0.0.1', 49950): veli: selam
- DEBUG - 01.10.2019 13:45:15 - ('127.0.0.1', 49950): veli: naber
- DEBUG - 01.10.2019 13:45:15 - ('127.0.0.1', 49950): veli: naber
- DEBUG - 01.10.2019 13:45:17 - ('127.0.0.1', 49950): veli: iyi misin?
- DEBUG - 01.10.2019 13:45:17 - ('127.0.0.1', 49950): veli: iyi misin?
- INFO - 01.10.2019 13:45:19 - ('127.0.0.1', 49950) is disconnected.
- INFO - 01.10.2019 13:45:27 - ('127.0.0.1', 49953) is connected.
- DEBUG - 01.10.2019 13:45:29 - ('127.0.0.1', 49953): ahahaha: ehehe
- DEBUG - 01.10.2019 13:45:29 - ('127.0.0.1', 49953): ahahaha: ehehe
- DEBUG - 01.10.2019 13:45:30 - ('127.0.0.1', 49953): ahahaha: ehehe
- DEBUG - 01.10.2019 13:45:30 - ('127.0.0.1', 49953): ahahaha: ehehe
- DEBUG - 01.10.2019 13:45:31 - ('127.0.0.1', 49953): ahahaha: ehehe
- DEBUG - 01.10.2019 13:45:31 - ('127.0.0.1', 49953): ahahaha: ehehe
- INFO - 01.10.2019 13:45:33 - ('127.0.0.1', 49953) is disconnected.
- INFO - 01.10.2019 13:45:34 - ('127.0.0.1', 49947) is disconnected.

Değiştirilen kodlar şu şekilde:

    async def client_connected(self, reader, writer):
        client = f"{writer.get_extra_info('peername')}"
        print(f"{client} is connected.")
        logging.info(f"{client} is connected.")
        self.clients.append((writer, reader))
        while True:            
            try:
                data = await reader.readline()
            except (BrokenPipeError, ConnectionResetError):
                data = "".encode()
            msg = f"{client}: {data.decode()}"
            if msg.encode() == f"{client}: ".encode():
                writer.close()
                print(f"{client} is disconnected.")
                logging.info(f"{client} is disconnected.")
                try:
                    await writer.wait_closed()
                except Exception:
                    pass
                self.clients.remove((writer, reader))                
                break
            else:
                for i in self.clients:
                    i[0].write(msg.encode())
                    logging.debug(msg[:-1])
                    await i[0].drain()

Evet hata çözülmüş görünüyor :slight_smile: