Skip to content

Commit

Permalink
Added close method to terminate the writer
Browse files Browse the repository at this point in the history
  • Loading branch information
ForceFledgling committed Nov 26, 2023
1 parent 48c0dd1 commit c32063e
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions asyncio_telnet/asyncio_telnet.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,23 @@ async def filter_telnet_data(self, data):
filtered_data += data[i:i+1]
i += 1
return filtered_data

async def close(self):
"""
Closes the writer associated with the current instance.
If a writer is present, this method first ensures any pending data is
flushed using `await self.writer.drain()`. It then closes the writer
using `self.writer.close()` and waits until the writer is fully closed
with `await self.writer.wait_closed()`.
Note: It is essential to call this method to gracefully close the writer
and release associated resources.
"""
if self.writer:
await self.writer.drain()
self.writer.close()
await self.writer.wait_closed()


class AsyncToSyncWrapper:
Expand Down

0 comments on commit c32063e

Please sign in to comment.