Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

gh-65920: Implementsocket.sendfile withTransmitFile on Windows#112337

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
aisk wants to merge11 commits intopython:main
base:main
Choose a base branch
Loading
fromaisk:windows-socket-sendfile
Open
Changes from1 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
PrevPrevious commit
NextNext commit
fix tests
  • Loading branch information
@aisk
aisk committedNov 23, 2023
commit3f7259fa7dbba7bc81e076f9e7da6ac4d65e0b22
14 changes: 11 additions & 3 deletionsLib/socket.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -468,7 +468,15 @@ def _sendfile_use_transmitfile(self, file, offset=0, count=None):
offset_low = offset & 0xffff_ffff
offset_high = (offset >> 32) & 0xffff_ffff
count = count or 0
ov.TransmitFile(self.fileno(), msvcrt.get_osfhandle(file.fileno()),
try:
fileno = file.fileno()
except (AttributeError, io.UnsupportedOperation) as err:
raise _GiveupOnSendfile(err) # not a regular file
try:
os.fstat(fileno)
except OSError as err:
raise _GiveupOnSendfile(err) # not a regular file
ov.TransmitFile(self.fileno(), msvcrt.get_osfhandle(fileno),
offset_low, offset_high, count, 0, 0)
timeout_ms = _overlapped.INFINITE
if timeout is not None:
Expand DownExpand Up@@ -514,9 +522,9 @@ def sendfile(self, file, offset=0, count=None):
The socket must be of SOCK_STREAM type.
Non-blocking sockets are not supported.
"""
if sys.platform == "win32":
return self._sendfile_use_transmitfile(file, offset, count)
try:
if sys.platform == "win32":
return self._sendfile_use_transmitfile(file, offset, count)
return self._sendfile_use_sendfile(file, offset, count)
except _GiveupOnSendfile:
return self._sendfile_use_send(file, offset, count)
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp