How long do background tasks stay in the list?

I keep trying to think of a way other than this:

And I really can’t think of a better way.

Especially if you are doing this (which I just read and think is a really great solution):

I would have a table with literally just one column of running ID’s.

  1. The ID’s would be added when the task was generated by another function before being passed back to the client.
  2. To do what you wanted I would do a app_tables.running_btaskID_table.get(job_id) for your job ID, if it was None then your job is completed.
  3. Finally if it is not None, to a .search() on the table and test each running task with task.is_running(), deleting the rows of any that return False.
  4. Finally Finally, repeat step 2 and return the result of if your task was still running.
2 Likes