Today we’re delighted to announce Background Tasks, our latest addition to Anvil.
Now you can kick off long-running processes and monitor their progress without blocking your app.
@anvil.server.background_task to mark a function as a Background Task:
@anvil.server.background_task def crawl_the_web(url): """In the background, crawl the web.""" recursively_index(url)
Then launch it using
task = anvil.server.launch_background_task('crawl_the_web', 'https://wikipedia.org/')
Use Background Tasks for heavyweight calculations, housekeeping processes, connection pools, downloading large files, anything you want to do in the background while the user carries on interacting with your app.
Learn how to trigger Background Tasks, communicate with them, and manage them, by following the tutorial. You’ll build a web crawler that fetches all the pages in a given website.
Or open the example in Anvil and investigate!