Skip to content

Commit

Permalink
force datapath insert/update request(s) to run synchronously before r…
Browse files Browse the repository at this point in the history
…eturning _ResultSet

The old code ran the HTTP request prior to returning, so we should do
the same, even if it is multiple requests due to batching.
  • Loading branch information
karlcz committed Aug 26, 2024
1 parent 62cdc87 commit 3344f9b
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions deriva/core/datapath.py
Original file line number Diff line number Diff line change
Expand Up @@ -747,7 +747,7 @@ def _generate_batches(entities, max_batch_rows=1000, max_batch_bytes=250*1024):
upper += 1

# generate one batch and advance for next batch
logger.debug("generating batch of %d/%d entities (%d:%d)" % (upper-lower, top, lower, upper))
logger.debug("yielding batch of %d/%d entities (%d:%d)" % (upper-lower, top, lower, upper))
yield entities[lower:upper]
lower = upper

Expand Down Expand Up @@ -1028,7 +1028,9 @@ def results_func(ignore1, ignore2, ignore3):
results.extend(resp.json())
return results

return _ResultSet(self.path.uri, results_func)
result = _ResultSet(self.path.uri, results_func)
result.fetch()
return result


def update(self, entities, correlation={'RID'}, targets=None, retry_codes={408, 429, 500, 502, 503, 504}, backoff_factor=4, max_attempts=5, max_batch_rows=1000, max_batch_bytes=250*1024):
Expand Down Expand Up @@ -1109,7 +1111,9 @@ def results_func(ignore1, ignore2, ignore3):
results.extend(resp.json())
return results

return _ResultSet(self.path.uri, results_func)
result = _ResultSet(self.path.uri, results_func)
result.fetch()
return result

class _TableAlias (_TableWrapper):
"""Represents a table alias in datapath expressions.
Expand Down

0 comments on commit 3344f9b

Please sign in to comment.