jquast / telnetlib3

Python Telnet server and client Protocol library using asyncio

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

AttributeError on wait_closed() after close()

alexdelprete opened this issue · comments

Hi,

thanks for telnetlib3.

I found this problem was already reported in #55 and #62, but since they were closed issues, I opened a new one:

    try:
        reader, writer = await telnetlib3.open_connection(host, port)
    ...
    ...
    except asyncio.TimeoutError:
        print("Connection or operation timed out")

    except Exception as e:
        print(f"An error occurred: {str(e)}")

    finally:
        if not writer.transport.is_closing():
            writer.close()
            await writer.wait_closed()

Throws this error:

Traceback (most recent call last):
  File "d:\Google Drive\Home Assistant\Dev\ha-elios4you\custom_components\elios4you\test\e4u.py", line 58, in <module>
    asyncio.run(main())
  File "C:\Users\aless\AppData\Local\Programs\Python\Python310\lib\asyncio\runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "C:\Users\aless\AppData\Local\Programs\Python\Python310\lib\asyncio\base_events.py", line 649, in run_until_complete
    return future.result()
  File "d:\Google Drive\Home Assistant\Dev\ha-elios4you\custom_components\elios4you\test\e4u.py", line 55, in main
    await writer.wait_closed()
AttributeError: 'TelnetWriterUnicode' object has no attribute 'wait_closed'