Show More
@@ -69,6 +69,13 b' def ismainthread():' | |||||
69 |
|
69 | |||
70 |
|
70 | |||
71 | class _blockingreader: |
|
71 | class _blockingreader: | |
|
72 | """Wrap unbuffered stream such that pickle.load() works with it. | |||
|
73 | ||||
|
74 | pickle.load() expects that calls to read() and readinto() read as many | |||
|
75 | bytes as requested. On EOF, it is fine to read fewer bytes. In this case, | |||
|
76 | pickle.load() raises an EOFError. | |||
|
77 | """ | |||
|
78 | ||||
72 | def __init__(self, wrapped): |
|
79 | def __init__(self, wrapped): | |
73 | self._wrapped = wrapped |
|
80 | self._wrapped = wrapped | |
74 |
|
81 | |||
@@ -94,7 +101,7 b' class _blockingreader:' | |||||
94 | def readline(self): |
|
101 | def readline(self): | |
95 | return self._wrapped.readline() |
|
102 | return self._wrapped.readline() | |
96 |
|
103 | |||
97 | # issue multiple reads until size is fulfilled |
|
104 | # issue multiple reads until size is fulfilled (or EOF is encountered) | |
98 | def read(self, size=-1): |
|
105 | def read(self, size=-1): | |
99 | if size < 0: |
|
106 | if size < 0: | |
100 | return self._wrapped.readall() |
|
107 | return self._wrapped.readall() |
General Comments 0
You need to be logged in to leave comments.
Login now