-
-
Notifications
You must be signed in to change notification settings - Fork 18
Open
Description
Hi, I noticed you've added mmap to the code, which is great!
Unfortunately, it breaks consuming http streams, because urllib3 raw streams (urllib3.response.HTTPResponse) also (surprisingly) have a fileno!
So we get an exception:
in get_memoryview(data)
98 # Handle file object opened in 'rb' mode
99 if hasattr(data, "fileno"):
--> 100 mm = mmap.mmap(data.fileno(), 0, access=mmap.ACCESS_READ)
101 return memoryview(mm)
103 # Handle BufferedReader
OSError: [Errno 22] Invalid argumentI've checked the set difference of attributes of a binary file handle and a HTTPResponse, and these attributes are (on my macos machine) exclusively available on files:
['_dealloc_warn',
'_finalizing',
'detach',
'mode',
'name',
'peek',
'raw',
'readinto1',
'write']
So it may be worth either switching the check or alternatively adding an extra condition that prevents mmap on urllib3.response.HTTPResponse objects.
Cheers!
Metadata
Metadata
Assignees
Labels
No labels