File tree 1 file changed +5
-12
lines changed
1 file changed +5
-12
lines changed Original file line number Diff line number Diff line change @@ -191,19 +191,12 @@ def deallocate(self, buf):
191
191
buffer_ (io.BytesIO): The buffer to return
192
192
"""
193
193
with self ._lock :
194
- capacity = buf .seek (0 , 2 )
195
-
196
- # free extra memory if needed
197
- if capacity > self ._poolable_size :
198
- # BytesIO (cpython) only frees memory if 2x reduction or more
199
- trunc_to = int (min (capacity / 2 , self ._poolable_size ))
200
- buf .truncate (trunc_to )
201
-
202
- buf .seek (0 )
203
- #buf.write(bytearray(12))
204
- #buf.seek(0)
194
+ # BytesIO.truncate here makes the pool somewhat pointless
195
+ # but we stick with the BufferPool API until migrating to
196
+ # bytesarray / memoryview. The buffer we return must not
197
+ # expose any prior data on read().
198
+ buf .truncate (0 )
205
199
self ._free .append (buf )
206
-
207
200
if self ._waiters :
208
201
self ._waiters [0 ].notify ()
209
202
You can’t perform that action at this time.
0 commit comments