Skip to content

Commit

Permalink
Save a reference to created tasks, to avoid tasks disappearing (#17946)
Browse files Browse the repository at this point in the history
Co-authored-by: Adrian Wälchli <aedu.waelchli@gmail.com>
(cherry picked from commit 658e1ab)
  • Loading branch information
anio authored and Borda committed Jul 7, 2023
1 parent 90354bd commit dcf1c2b
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/lightning/app/components/serve/auto_scaler.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,9 @@ async def consumer(self):
if batch and (is_batch_ready or is_batch_timeout):
self._server_status[server_url] = False
# find server with capacity
asyncio.create_task(self.send_batch(batch, server_url))
# Saving a reference to the result of this function, protects the task disappearing mid-execution
# https://docs.python.org/3/library/asyncio-task.html#asyncio.create_task
task = asyncio.create_task(self.send_batch(batch, server_url)) # noqa: F841
# resetting the batch array, TODO - not locking the array
self._batch = self._batch[len(batch) :]
self._last_batch_sent = time.time()
Expand Down

0 comments on commit dcf1c2b

Please sign in to comment.