Task execution is aborted due to timeout

I am trying to download the movies that an actor played in through the IMDb API and save them in the database.

This is the log output I get:

6:27:45.9 | SERVER_CODE | INFO | [24402] Your Honor
6:27:45.9 | SERVER_CODE | INFO | [24402] 180/464
6:27:45.142 | SERVER_CODE | INFO | [24402] Sneaky Pete
6:27:45.143 | SERVER_CODE | INFO | [24402] 181/464
6:27:45.275 | SERVER_CODE | INFO | [24402] Modern Family
6:27:45.275 | SERVER_CODE | INFO | [24402] 182/464
6:27:45.337 | SERVER_CODE | INFO | [24402] Breaking Bad
6:27:45.337 | SERVER_CODE | INFO | [24402] 183/464
6:27:45.720 | SERVER_CODE | ERROR | [24402] Task execution is aborted due to timeout
6:27:45.721 | SERVER_CODE | INFO | [24402] Processing finished in 20031.472ms
6:27:45.721 | SERVER_CODE | INFO | [24402] Task results sent
6:27:45.721 | SERVER_CODE | INFO | [24402] Flushing logs

How do I work around this issue?

I would have uploaded a screenshot of the code but I get this error:
Sorry, there was an error uploading that file. Please try again.

Hello @Hans_Muster

Welcome to the Backendless Community!
The script/code execution time limit is described here Backendless Cloud Pricing | Low Cost No-Code App Development Platform. You can purchase Enhanced Script/Code Execution Time (20 sec) function pack in marketplace to increase the limit.

Regards,
Inna

Thank you for your reply.

Is it possible to buy multiple of this package?

If not, what would be the proper course of action if I download data from an API that takes 10 minutes?

Yes, it is possible to buy several packs.

Regards,
Inna

I found two solutions to work around this issue:

  1. Using “Bulk Create” for the database objects increases the speed tremendously

  2. Using recursion, where I use two API Services

  • The first one downloads the JSON of movies into a database field and then calls the second one
  • which calls itself after each “Bulk Create” of 100 objects from the JSON objects in the database. Even if there are still timeout warnings, it doesn’t matter because the recursive calls are already executed and running.