From 3950f25a43ae8b795964a13f48e170761ffc056d Mon Sep 17 00:00:00 2001 From: d-w-moore Date: Sun, 19 Nov 2023 22:22:32 -0500 Subject: [PATCH] introduce buffering parameter in open() whitespace --- irods/manager/data_object_manager.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/irods/manager/data_object_manager.py b/irods/manager/data_object_manager.py index f1b2169f..93fc91e5 100644 --- a/irods/manager/data_object_manager.py +++ b/irods/manager/data_object_manager.py @@ -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. @@ -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):