Frontend and Backend Timeout Questions

What I’m trying to do:
Create a simple one off utility to import a CSV file into my application. Everything looks to be going well (correct rows getting inserted but not all of them), then it appears that the function times out and doesn’t complete the operation (both front and backend code versions). I’d like to figure out what I’m doing wrong here?

What I’ve tried and what’s not working:

Front End
I can correctly parse (as far as I can tell) a CSV string I’ve pasted into my ISPsByLocation, and then attempt to insert it using the function call:

 anvil.server.call('insert_ispbylocation_rows', data_rows_list = data_rows_list, header_rows_list = header_rows_list, state = new_hampshire)

Back End
Same function essentially, just defined on the front end and called:

self.insert_ispbylocation_rows(data_rows_list = data_rows_list, header_rows_list = header_rows_list, state = new_hampshire)

Gives the same functionality. Inserts some rows, but then times out and doesn’t finish.

Clone link:
https://anvil.works/build#clone:6GW5AWDZCW65P6FR=CUCAF36YL4J44DQBWZHJA4TX

CSV:
I would upload the file, but I’m not allowed to upload CSV files, so I’ll just leave it in this post in case anyone wants to look at the sample data I’m using.

,FairPoint Communications,Xfinity Store by Comcast,Adored WiFi,vUnity Business Internet,Local Net,Minim,Windstream,Metro 2000,2DIFORE Marketing Solutions,Firstlight Fiber
Manchester,875 Holt Ave Manchester NH 03109,1500 S Willow St #104 Manchester NH 03103,848 Elm St Suite 200 Manchester NH 03101,359 Elm St Manchester NH 03101,Manchester NH 03101 United States,848 Elm St Manchester NH 03101 United States,1000 Elm St 2nd floor suite 201 Manchester NH 03101 United States,1 Sundial Ave # 310 Manchester NH 03103 United States,37 Heritage Way Manchester NH 03104 United States,77 Sundial Ave Manchester NH 03103 United States
Nashua,124 W Pearl St Nashua NH 03060 United States,219 Daniel Webster Hwy Nashua NH 03060 United States,,,,,,,,
Concord,12 South St Concord NH 03301 United States,,,,Concord NH 03301 United States,,,,,
Derry,52 E Broadway Derry NH 03038 United States,,,,,,,,,
Dover,,,,,Dover NH 03820 United States,,,,,
Rochester,11 Dreyer Way Rochester NH 03867 United States,,,,,,,,,
Salem,,,,,,,,,,
Merrimack,,,,,,,,,,
Londonderry,,,,,,,,,,
Hudson,18-20 Bockes Rd Hudson NH 03051 United States,,,,,,,,,
Keene,,,,,Keene NH 03431 United States,,,,,
Bedford,,,,,,,,,,8 Commerce Dr Bedford NH 03110 United States
Portsmouth,,180 Greenleaf Ave Portsmouth NH 03801 United States,,,Portsmouth NH 03801 United States,,,,,
Goffstown,14 White St Goffstown NH 03045 United States,,,,,,,,,
Laconia,762 N Main St Laconia NH 03246 United States,,,,,,,,,
Durham,,,,,,,,,,
Milford,194 South St Milford NH 03055 United States,,,,,,,,,
Hampton,151 Winnacunnet Rd Hampton NH 03842 United States,,,,,,,,,
Exeter,15 Center St Exeter NH 03833 United States,,,,,,,,,
Windham,,,,,,,,,,
Hooksett,,,,,,,,,,
Pelham,,,,,,,,,,
Lebanon,20 Bank St Lebanon NH 03766 United States,,,,Lebanon NH 03766 United States,,,,,
Claremont,,,,,,,,,,
Somersworth,,,,,,,,,,
Hanover,,,,,,,,,,
Amherst,,,,,,,,,,
Raymond,,,,,,,,,,
Conway,27 Kearsarge Rd North Conway NH 03860 United States,,,,Conway NH 03818 United States,,,,,
Berlin,,,,,93 Green St Berlin NH 03570 United States,,,,,
Newmarket,8 Gerry Ave Newmarket NH 03857 United States,,,,,,,,,
Barrington,383 Franklin Pierce Hwy Barrington NH 03825 United States,,,,,,,,,
Weare,,,,,,,,,,
Seabrook,,,,,,,,,,
Franklin,76 Franklin St Franklin NH 03235 United States,,,,,,,,,
Litchfield,,,,,,,,,,
Hampstead,,,,,,,,,,
Hollis,,,,,,,,,,
Bow,,,,,,,,,,
Plaistow,,,,,,,,,,
Stratham,,,,,,,,,,
Belmont,7 Gale St Belmont NH 03220 United States,,,,,,,,,
Pembroke,16 Pleasant St Suncook NH 03275 United States,,,,,,,,,
Swanzey,,,,,,,,,,
Gilford,1203 Weirs Blvd Laconia NH 03246 United States,1458 Lake Shore Rd Suite A-130 Gilford NH 03249 United States,,,,,,,,
Atkinson,,70 Pleasant Valley St Methuen MA 01844 United States,,,,,,,,
Epping,,,,,,,,,,
Farmington,369 Main St Farmington NH 03835 United States,,,,,,,,,
Plymouth,,,,,Plymouth NH 03264 United States,,,,,
Peterborough,,,,,Peterborough NH 03458 United States,,,,,
Sandown,,,,,,,,,,
Meredith,11 Water St Meredith NH 03253 United States,,,,,,,,,
Newport,Maple St Newport NH 03773 United States,,,,,,,,,
Wolfeboro,43 Glendon St Wolfeboro NH 03894 United States,,,,Wolfeboro NH 03894 United States,,,,,
Kingston,,,,,,,,,,
Rindge,163 Main St Rindge NH 03461 United States,,,,,,,,,
Hillsborough,,,,,,,,,,
Littleton,,,,,Littleton NH 03561 United States,,,,,
New Boston,,,,,,,,,,
Hopkinton,,,,,,,,,,
Loudon,288 Shaker Rd Canterbury NH 03224 United States,,,,,,,,,
Auburn,,,,,,,,,,
Rye,,,,,,,,,,
Brookline,,,,,,,,,,
New Ipswich,,,,,,,,,,
Alton,,,,,,,,,,
Jaffrey,16 River St Jaffrey NH 03452 United States,,,,,,,,,
Chester,,,,,,,,,,
Nottingham,,,,,,,,,,
Wakefield,15 Cedar St Sanbornville NH 03872 United States,,,,,,,,,
Charlestown,33 Church St Charlestown NH 03603 United States,,,,,,,,,
Henniker,,,,,,,,,,
Newton,,,,,,,,,,
Northfield,,,,,,,,,,
Epsom,,,,,,,,,,
Fremont,,,,,,,,,,
Barnstead,,,,,,,,,,
Milton,,,,,,,,,,
Haverhill,,,,,,,,,,
Brentwood,,,,,,,,,,
Enfield,,,,,,,,,,
Danville,,,,,,,,,,
Lee,,,,,,,,,,
Deerfield,,,,,,,,,,
North Hampton,,,,,,,,,,
Allenstown,16 Pleasant St Suncook NH 03275 United States,,,,,,,,,
Ossipee,39 Folsom Rd Center Ossipee NH 03814 United States,,,,,,,,,
New London,,,,,,,,,,
Northwood,,,,,,,,,,
Winchester,,,,,,,,,,
Strafford,,,,,,,,,,
Moultonborough,31 Squam Lake Rd Sandwich NH 03227 United States,,,,,,,,,
Pittsfield,10 Bridge St Pittsfield NH 03263 United States,,,,,,,,,
Greenland,,,,,,,,,,
Boscawen,,,,,,,,,,
Walpole,,,,,,,,,,
Candia,,,,,,,,,,
Canaan,,,,,,,,,,
Hinsdale,,,,,Brattleboro VT 05301 United States,,,,,
Wilton,,,,,,,,,,
Gilmanton,,,,,,,,,,
Chesterfield,,,,,,,,,,
Tilton,19 Prospect St Tilton NH 03276 United States,,,,,,,,,
Sunapee,2 Maple St Sunapee NH 03782 United States,,,,,,,,,
Campton,371 Owl St Campton NH 03223 United States,,,,,,,,,
Lancaster,13 High St Lancaster NH 03584 United States,,,,Lancaster NH 03584 United States,,,,,
Bristol,,,,,,,,,,
Tamworth,49 Tamworth Rd Tamworth NH 03886 United States,,,,,,,,,
Sanbornton,,,,,,,,,,
Grantham,,,,,,,,,,
Warner,,,,,,,,,,
Dunbarton,,,,,,,,,,
Bartlett,18 George St Bartlett NH 03812 United States,,,,,,,,,
Plainfield,,,,,,,,,,
Andover,,,,,,,,,,
New Durham,,,,,,,,,,
Chichester,,,,,,,,,,
Antrim,,,,,,,,,,
Mont Vernon,,,,,,,,,,
Gorham,22 Lancaster Rd Gorham NH 03581 United States,,,,,,,,,
Bethlehem,Cross St Bethlehem NH 03574 United States,,,,,,,,,
Madison and Rollinsford,,,,,,,,,,
Thornton,371 Owl St Campton NH 03223 United States,,,,,,,,,
Marlborough,,,,,,,,,,
New Hampton ,21 Spring St Bristol NH 03222 United States,,,,,,,,,
Canterbury,288 Shaker Rd Canterbury NH 03224 United States,,,,,,,,,
Fitzwilliam,11 Upper Troy Rd Fitzwilliam NH 03447 United States,,,,,,,,,
Ashland,,,,,,,,,,
Madbury,,,,,,,,,,
Hampton Falls,,,,,,,,,,
Holderness,,,,,,,,,,
Greenville,,,,,,,,,,
East Kingston,,,,,,,,,,
Sutton,,,,,,,,,,
Whitefield,12 Pleasant St Whitefield NH 03598 United States,,,,,,,,,
Tuftonboro,,,,,,,,,,
Westmoreland,,,,,,,,,,
Kensington,,,,,,,,,,
Webster,,,,,,,,,,
Alexandria,,,,,,,,,,
Newfields,,,,,,,,,,
Colebrook,197 Main St Colebrook NH 03576 United States,,,,,,,,,
Northumberland,,,,,,,,,,
Greenfield ,,,,,,,,,,
Newbury ,,,,,,,,,,
Troy and Lyndeborough ,,,,,,,,,,
Deering ,,,,,,,,,,
Lyme,,,,,,,,,,
Hancock,Main St Harrisville NH 03450 United States,,,,,,,,,
Bennington,,,,,,,,,,
Alstead,,,,,,,,,,
Cornish ,,,,,,,,,,
Effingham,,,,,,,,,,

So, what are the timeouts for front and back end? I’ve researched on the forums, and it seems to be about 20 to 30 seconds. Not sure do I need to wrap this in a background task? Seems like the most straightforward approach.

I tried the clone and clicking the button worked fine with the CSV you pasted.
I added a print("done") at the end of the running function and it successfully completed.
I didn’t try to follow the logic of the app.


You may have spotted the add_rows feature in accelerated tables which may speed things up.


The timeout for server functions is 30 seconds.

There is no timeout for client-side functions.


(if you want to do a long running client-side task (no server calls) then anvil-labs has client side background tasks)


A background task is probably the way to go if you’re getting close to the 30 second limit

1 Like

I just noticed what I did. I was expecting all rows to be in there, but I only coded it so that way only locations with ISPs got inserted. Logic error this time :slight_smile: