0

I am new to python, so this is a very basic error on my part, I just don't see it...
In the code below, I am expecting that if the data seen by tn.read_until, (calll:), is not seen, the script will run the block of code below 'except', and the exitscript() function will be called...

That appears to not be happening... It is as if no error is being raised, the script just ignores the entire 'except" path. Can someone explain what I am missing here please? I suspect I am not looking for the right trigger here...

Code follows:

try:                                                               
    tn.read_until(b"calll:", timeout=5)                            
except EOFError:
    logdata = 'Timeout reached in login.'
    logit(logdata)                                                
    failcode = 4
    exitscript()                                                    # Leave script, EC4 set.
else:
    tn.write(USER.encode("ascii") + b"\n")                          

rest of script...

Dave
  • 1
  • 2
  • An `EOFErrror` happens when the input stream is closed, NOT when a timeout occurs. – VPfB Feb 16 '23 at 16:09
  • Why not put the `tn.write` line after the `tn.read_until` line? – treuss Feb 16 '23 at 16:09
  • VPfB: Thank you, that answers why it works in a different location, where I am testing for stream failure! – Dave Feb 16 '23 at 16:25
  • treuss: Thank you-- I am testing for a failure in timeout before I send data back, I want to be sure I have 'calll:', prior to sending my response. If the timeout period passes, won't the tn.write send the data anyway? – Dave Feb 16 '23 at 16:27

0 Answers0