Skip to content

Commit

Permalink
introduce buffering parameter in open()
Browse files Browse the repository at this point in the history
whitespace
  • Loading branch information
d-w-moore committed Aug 22, 2024
1 parent 2d968fe commit 3950f25
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions irods/manager/data_object_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,7 @@ def open(self, path, mode,
returned_values = None, # Used to update session reference, for forging more conns to same host, in irods.parallel.io_main
allow_redirect = True, # This may be set to False to disallow the client redirect-to-resource.
**options):
_buffering = options.pop('_buffering', -1)
_raw_fd_holder = options.get('_raw_fd_holder',[])
# If no keywords are used that would influence the server as to the choice of a storage resource,
# then use the default resource in the client configuration.
Expand Down Expand Up @@ -526,12 +527,19 @@ def make_FileOpenRequest(**extra_opts):
# Use case: auto_close has defaulted to the irods.configuration getter.
# access entry in irods.configuration
auto_close = auto_close()

bufopt = {}
if _buffering >= 0: # originally '>' - DWM
bufopt['buffer_size'] = _buffering

if auto_close:
ret_value = ManagedBufferedRandom(raw, _session = self.sess)
ret_value = ManagedBufferedRandom(raw, _session = self.sess, **bufopt)
else:
ret_value = io.BufferedRandom(raw)
ret_value = io.BufferedRandom(raw, **bufopt)

if 'a' in mode:
ret_value.seek(0,io.SEEK_END)

return ret_value

def replica_truncate(self, path, desired_size, **options):
Expand Down

0 comments on commit 3950f25

Please sign in to comment.