Skip to content

Commit

Permalink
Bulk processor bugfixes (#34)
Browse files Browse the repository at this point in the history
* error handling

* bump to next patch version
  • Loading branch information
philkra authored Feb 21, 2023
1 parent 2b9154e commit 5a2705b
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "xata"
version = "0.5.0"
version = "0.5.1"
description = "Python client for Xata.io"
authors = ["Xata <[email protected]>"]
license = "Apache-2.0"
Expand Down
2 changes: 1 addition & 1 deletion xata/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@

# TODO this is a manual task, to keep in sync with pyproject.toml
# could/should be automated to keep in sync
__version__ = "0.5.0"
__version__ = "0.5.1"

PERSONAL_API_KEY_LOCATION = "~/.config/xata/key"
DEFAULT_BASE_URL_DOMAIN = "xata.sh"
Expand Down
6 changes: 4 additions & 2 deletions xata/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,10 @@ def process(self, id: int):
if r.status_code != 200:
self.logger.error(
"thread #%d: unable to process batch for table '%s', with error: %d - %s"
% (id, batch["table"], r.status_code, r.json()["message"])
% (id, batch["table"], r.status_code, r.json())
)
# TODO add records to batch again or callback
raise Exception(r.json()["message"])
raise Exception(r.json())

self.logger.debug(
"thread #%d: pushed a batch of %d records to table %s"
Expand Down Expand Up @@ -165,7 +165,9 @@ def flush_queue(self):
self.logger.debug("flushing queue with %d records .." % (self.records.size()))
self.records.set_flush_interval(0)
self.processing_timeout = 0

while self.stats["queue"] > 0:
self.logger.debug("flushing queue with %d records." % self.stats["queue"])
time.sleep(self.processing_timeout / len(self.thread_workers) + 0.01)

class Records(object):
Expand Down

0 comments on commit 5a2705b

Please sign in to comment.