Skip to content

Commit f19ff13

Browse files
committed
Report progress from os.sendfile() and os.copy_file_range()
1 parent 777af5f commit f19ff13

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

Lib/pathlib/_os.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ def _copy_file_range(source_fd, target_fd):
8080
if sent == 0:
8181
break # EOF
8282
offset += sent
83+
yield sent
8384
else:
8485
_copy_file_range = None
8586

@@ -97,6 +98,7 @@ def _sendfile(source_fd, target_fd):
9798
if sent == 0:
9899
break # EOF
99100
offset += sent
101+
yield sent
100102
else:
101103
_sendfile = None
102104

@@ -141,14 +143,14 @@ def copyfileobj(source_f, target_f):
141143
raise err
142144
if _copy_file_range:
143145
try:
144-
_copy_file_range(source_fd, target_fd)
146+
yield from _copy_file_range(source_fd, target_fd)
145147
return
146148
except OSError as err:
147149
if err.errno not in (ETXTBSY, EXDEV):
148150
raise err
149151
if _sendfile:
150152
try:
151-
_sendfile(source_fd, target_fd)
153+
yield from _sendfile(source_fd, target_fd)
152154
return
153155
except OSError as err:
154156
if err.errno != ENOTSOCK:

0 commit comments

Comments
 (0)