Hi all,
Quite often I get internal server errors when writing to database rows. Most of the time this occurs when trying to write a bunch of rows at once using the app_tables.my_table.add_rows(my_rows)
.
So what I generally do is break my_rows
into batches of say 50 or 100, etc… My code might look something like this:
batch_size = 50
for k in range(0, len(rows), batch_size):
sub_rows = rows[k : k + batch_size]
app_tables.my_table.add_rows(sub_rows)
Often this solves the problem, but not always. Any other tips out there?
Anvil team, could you perhaps investigate the error:
anvil.server.InternalError: Internal server error: 9e40e254962d
I believe it to be a memory issue, but perhaps I might be wrong and therefore barking up the wrong tree.
UPDATE
The issue in this case was that were nan
’s present in the data I was trying to write to a simple_object column. Would be great if the error message could be a bit more intuitive. I removed the nan
’s, but there are certainly instances where the code above crashes due to what I believe are memory issues. After retrying, in most cases the code completes, but the internal server errors do occasionally pop up.