Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
use power of 2; catch OSError
  • Loading branch information
giampaolo committed Sep 30, 2019
commit 549e508c26776dd8193a2a64888ebacb11ef2208
4 changes: 2 additions & 2 deletions Lib/shutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,8 @@ def _fastcopy_sendfile(fsrc, fdst):
# changes while being copied.
try:
blocksize = max(os.fstat(infd).st_size, 2 ** 23) # min 8MB
blocksize = min(blocksize, 2 ** 31 - 2) # max 2GB
except Exception:
blocksize = min(blocksize, 2 ** 30) # max 1GB
except OSError:
blocksize = 2 ** 27 # 128MB

offset = 0
Expand Down
2 changes: 1 addition & 1 deletion Lib/socket.py
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ def _sendfile_use_sendfile(self, file, offset=0, count=None):
if not fsize:
return 0 # empty file
blocksize = fsize if not count else count

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
blocksize = fsize if not count else count
blocksize = count or fsize

blocksize = min(blocksize, 2 ** 31 - 2) # max 2GB
blocksize = min(blocksize, 2 ** 30) # max 1GB

timeout = self.gettimeout()
if timeout == 0:
Expand Down