Hi Everyone,
What I’m trying to do:
I have a web application that takes in a couple pieces of information from the client. The main piece of information being an Excel workbook along with some details. The web app then makes use of a callable function in the server code side that launches a background task that makes a couple request calls to a server that uploads the excel file and data.
What I’ve tried and what’s not working:
The issue that I am facing is that the web app times out when I make the call to the server code for the background task and doesn’t complete all the functions after the call to the server code. The client gets an error on screen and the logs show the same error: anvil.server.TimeoutError: Server code took too long
. The line that it is referirng to is the line that launches the background task in the server code.
The flow is as follows:
- Client adds details to
Form
and clicks submit. -
Form
calls ananvil.server.callable
function inserverModule
. -
serverModule
launches ananvil.server.background_task
usinganvil.server.launch_background_task
Code Sample:
# this is a formatted code snippet.
## Form Snippet
anvil.server.call("createWorkItem", self.file, self.sheet, self.fileName, self.fileSize, self.clientEmail, self.vendor)
## serverModule Snippet of callable function
@anvil.server.callable
def createWorkItem(file, sheet, fileName, fileSize, clientEmail, vendorName):
anvil.server.launch_background_task('createWorkItems', file, sheet, fileName, fileSize, clientEmail, vendorName)
## serverModule Snippet of background task
@anvil.server.background_task
def createWorkItems(file, sheet, fileName, fileSize, clientEmail, vendorName):
try:
doStuff()
except:
doOtherStuff()
# paste your code between ```