Santiago Vidal
Santiago Vidal

Reputation: 61

Python telnetlib read_all hangs until timeout

I have some Python code that connects via telnet to an OSPF daemon (ran by Quagga) and then does the following:

tn.write("show ip ospf database router\n")
tn.write("exit\n")
my_text = tn.read_all()

When the output of show ip ospf database router is small, the script works fine, but when it is big (approximately 73kb) the code freezes in the read_all() call until it timeouts.

My question is: why is this happening? Is there some sort of maximum size of output that read_all can handle?

I should note that if I use read_very_eager() instead of read_all() the code works fine.

Thank you in advance. Santiago Vidal.

Upvotes: 1

Views: 3959

Answers (1)

You can control the size of the output with the following line:

               Telnet.set_debuglevel (debuglevel)

Set the debug level. The higher the value of debuglevel, the more debug output you get (on sys.stdout).

For example:

tn.write("show ip ospf database router\n")
tn.write("exit\n")
my_text = tn.set_debuglevel(1000)
my_text = tn.read_all()

Upvotes: 1

Related Questions