Skip to content

Commit a907e40

Browse files
committed
Add buffer_size transport param to ssh.py
1 parent 749aa72 commit a907e40

2 files changed

Lines changed: 8 additions & 3 deletions

File tree

help.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ FUNCTIONS
254254
mode: str, optional
255255
The mode to use for opening the file.
256256
host: str, optional
257-
The hostname of the remote machine. May not be None.
257+
The hostname of the remote machine. May not be None.
258258
user: str, optional
259259
The username to use to login to the remote machine.
260260
If None, defaults to the name of the current user.
@@ -267,6 +267,8 @@ FUNCTIONS
267267
prefetch_kwargs: dict, optional
268268
Any additional settings to be passed to paramiko.SFTPFile.prefetch.
269269
The presence of this dict (even if empty) triggers prefetching.
270+
buffer_size: int, optional
271+
Passed as bufsize argument to paramiko.SFTPClient.open.
270272

271273
webhdfs (smart_open/webhdfs.py)
272274
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

smart_open/ssh.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,7 @@ def open(
226226
port=None,
227227
connect_kwargs=None,
228228
prefetch_kwargs=None,
229+
buffer_size=-1,
229230
):
230231
"""Open a file on a remote machine over SSH.
231232
@@ -238,7 +239,7 @@ def open(
238239
mode: str, optional
239240
The mode to use for opening the file.
240241
host: str, optional
241-
The hostname of the remote machine. May not be None.
242+
The hostname of the remote machine. May not be None.
242243
user: str, optional
243244
The username to use to login to the remote machine.
244245
If None, defaults to the name of the current user.
@@ -251,6 +252,8 @@ def open(
251252
prefetch_kwargs: dict, optional
252253
Any additional settings to be passed to paramiko.SFTPFile.prefetch.
253254
The presence of this dict (even if empty) triggers prefetching.
255+
buffer_size: int, optional
256+
Passed as bufsize argument to paramiko.SFTPClient.open.
254257
255258
Returns
256259
-------
@@ -297,7 +300,7 @@ def open(
297300
#
298301
del _SSH[key]
299302

300-
fobj = sftp_client.open(path, mode)
303+
fobj = sftp_client.open(path, mode=mode, bufsize=buffer_size)
301304
fobj.name = path
302305
if prefetch_kwargs is not None:
303306
fobj.prefetch(**prefetch_kwargs)

0 commit comments

Comments
 (0)