Is the server timeout limit depends on what plan you have?

Is the server timeout limit depends on what plan you have?

1 Like

Yes, sort of!

On all plans, the timeout for a Server Function call (ie anvil.server.call()) is 30 seconds.

However, if you want to perform a longer-running task, you can use Background Tasks. For those, Free plans are currently limited to 30 seconds, but paid plans can run for hours if necessary.

3 Likes

Hi, I’m using personal plan. How can I increase the timeout to 1 minute? Thanks!

If you are talking about timeouts for server functions, you can’t increase it beyond 30 seconds on any plan. But since you have a Personal Plan, you can run Background Tasks for as long as you want.

How would that help?

You can move server functions that are longer than 30 seconds to Background Tasks. Refer to the docs for more about it.

1 Like

Does that allow my process to complete?

Edit: I saw that the background tasks run when the form opens, how can I make it run when I click on a button?

I think you are confusing Background Tasks with something else. Background Tasks run on the server side when you use the anvil.server.launch_background_task function. Events like form show or button click have no relation with it (unless you are calling a server function on that event that launches a background task.

yes, that’s what I’m trying to do: calling a server function on click event which launches the background task.

I did try launching background task before calling the server function on click event but I get this error

image

//client side

rcot,refno=anvil.server.call('launch_slow_request_task',dd,storage.local_storage.get('br_code'),listmst)   
print('rcowt',rcot,type(rcot)) 
//server side

@anvil.server.callable
def launch_slow_request_task(detvalue,brcode,listmst):
  task = anvil.server.launch_background_task('insert_into_det_1', detvalue, brcode, listmst)
  return task

@anvil.server.background_task
def insert_into_det_1(detvalue,brcode,listmst): 
  print('---------------------------------------------------------------')
  # print(listmst)
  print('---------------------------------------------------------------')
....................... the rest of the function

Look up Background Tasks in the documentation to see how they are supposed to be used.

Think about it: if the task’s result was available right away, it wouldn’t be a background task, would it? The result of creating a task is, therefore, (an object representing) the ongoing task itself.

With this “handle”, you can ask the task how it is progressing, without interrupting the task, or interrupting your browser’s operation. You can ask whether it is done, whether it ended normally, or via an exception.

Not a lot of fancy features, just the essentials, to keep things simple. Very much worth a read.

1 Like

And please don’t ask the same question twice.

2 Likes