Tory Hoke

Essays, art, and comics of the unexpected

FOLLOW:

Telnetlib not reading all output? Try asynchat

More

Most Recent Posts

Day 1: An Overview

(Experience this as a TikTok.) “Play is the work of childhood.” – Jean Piaget “or children, play is serious learning.” – Mr. Rogers Adult learning is

Read More »

Telnetlib not reading all output? Not receiving all the output from your telnetlib session? read_until() not an option because you don’t know what output to look for? telnetlib not queueing your writes?

Think you want a telnetlib alternative, but Google isn’t turning anything up?

I’ve been there.

Headbanging Gods of Metal Traveller
There was head-banging, but it was not a ball
Image stolen from Metal Traveller

After a couple of days of madness I learned a few things:

– In Maya at least, not all output generated by the server is available to be read. I can call print("foo") all day and never read back “foo” on the client. Apparently it is known that “python print does not appear in certain output”. I ended up using the mel warning command, and if you think that sounds like overkill you are probably right.

– After much much much Googling, this stackoverflow answer pointed me to asynchat. I ended up writing a tiny client by extending asynchat, and Turns out I didn’t want a telnetlib alternative; I wanted a module that did much less!

not a python but still happy

Not a python but still happy

telnetlib doesn’t seem to queue writes. You can send two writes in a row, but there’s no guarantee the second one will be received by the server. Troublesome if you’re trying to use a second write as a way to determine when the first write has finished executing. Fortunately asynchat.push() works like a boss.

– More information and a code sample can be found at stackoverflow. I have personal insight on a code problem about once in a bazillion years, so this is very exciting to me.

If this post helps one person headbang only by choice, I have succeeded.

Share This:

Comics: Rare Words

Comics: Sneaky VFX

Comics: Pure Silliness