Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#491] introduce buffering parameter in open() #492

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Changes from all commits
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
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