SuspensionError - accessing more than 100 rows from SearchIterator

I got the following error after the first 100 rows are printed when run the code below
SuspensionError: Cannot call a function that blocks or suspends here at

I guess 100 is the limit according to this post?

def button_1_click(self, **event_args):
    """This method is called when the button is clicked"""
    self.all_row = anvil.server.call('get_all_rows')  

    for i, row in enumerate(self.all_row):
      print(i, row['word'])

@anvil.server.callable
def get_all_rows():
  rows = app_tables.reading.search()
  return rows

That post does not mention or describe a limit. The exception comes from the way that Python is translated into Javascript, for the browser to run. There are a few, rare, oddball cases that work just fine by themselves, but when forced to work together, can’t, because both parts are trying to use the same (behind-the-scenes, non-shareable) machinery.

The general solution is to break down the steps a little more, so that those particular steps no longer combine. For more details, please see the post you quoted.

1 Like

The quick fix is to replace self.all_rows with list(self.all_rows) before calling enumerate

2 Likes

It works really appreciate that @stucork
Thanks @p.colbert for explanation for the quoted post.