File tree 1 file changed +6
-4
lines changed
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):
92
92
"""
93
93
self .send (data )
94
94
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
+
97
99
# print("Socket readline")
98
100
stamp = time .monotonic ()
99
- while b" \r \n " not in self ._buffer :
101
+ while eol not in self ._buffer :
100
102
# there's no line already in there, read some more
101
103
avail = self .available ()
102
104
if avail :
103
105
self ._buffer += _the_interface .socket_read (self ._socknum , avail )
104
106
elif self ._timeout > 0 and time .monotonic () - stamp > self ._timeout :
105
107
self .close () # Make sure to close socket so that we don't exhaust sockets.
106
108
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 )
108
110
gc .collect ()
109
111
return firstline
110
112
You can’t perform that action at this time.
0 commit comments