ospfsock: Wait for the socket answer

The error handling is horrible though.
master
LEdoian 1 year ago
parent cafdd3cd07
commit e95ca088a5

@ -3,6 +3,7 @@
from dataclasses import dataclass,field from dataclasses import dataclass,field
import socket as sk import socket as sk
from string import digits from string import digits
from select import select
class BirdError(Exception): class BirdError(Exception):
def __init__(self, code, where, text): def __init__(self, code, where, text):
@ -55,6 +56,10 @@ class BirdSocketConnection:
code : str | None = None # string because of leading zeroes, and it has no numeric interpretation anyway code : str | None = None # string because of leading zeroes, and it has no numeric interpretation anyway
start = None start = None
cont = True cont = True
# The response might not yet be ready
rrdy, wrdy, xrdy = select([self.socket], [], [], 1)
if len(rrdy) == 0:
print('WTF, no response in 1 second?')
f = self.socket.makefile('r') f = self.socket.makefile('r')
for i, line in enumerate(f, start=1): for i, line in enumerate(f, start=1):
assert cont, "WTF bad format (should not continue)." assert cont, "WTF bad format (should not continue)."

Loading…
Cancel
Save