File tree Expand file tree Collapse file tree 1 file changed +6
-4
lines changed Expand file tree Collapse file tree 1 file changed +6
-4
lines changed Original file line number Diff line number Diff line change @@ -92,19 +92,21 @@ def write(self, data):
9292 """
9393 self .send (data )
9494
95- def readline (self ):
96- """Attempt to return as many bytes as we can up to but not including '\r \n '"""
95+ def readline (self , eol = b"\r \n " ):
96+ """Attempt to return as many bytes as we can up to but not including
97+ end-of-line character (default is '\\ r\\ n')"""
98+
9799 # print("Socket readline")
98100 stamp = time .monotonic ()
99- while b" \r \n " not in self ._buffer :
101+ while eol not in self ._buffer :
100102 # there's no line already in there, read some more
101103 avail = self .available ()
102104 if avail :
103105 self ._buffer += _the_interface .socket_read (self ._socknum , avail )
104106 elif self ._timeout > 0 and time .monotonic () - stamp > self ._timeout :
105107 self .close () # Make sure to close socket so that we don't exhaust sockets.
106108 raise RuntimeError ("Didn't receive full response, failing out" )
107- firstline , self ._buffer = self ._buffer .split (b" \r \n " , 1 )
109+ firstline , self ._buffer = self ._buffer .split (eol , 1 )
108110 gc .collect ()
109111 return firstline
110112
You can’t perform that action at this time.
0 commit comments