Skip to content

Commit

Permalink
Don't exit live generation loop when switching documents
Browse files Browse the repository at this point in the history
  • Loading branch information
modelflat committed Nov 26, 2024
1 parent 80b2bc4 commit 98e64d8
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions ai_diffusion/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -885,16 +885,17 @@ def handle_job_finished(self, job: Job):
eventloop.run(_report_errors(self._model, self._continue_generating()))

async def _continue_generating(self):
while self.is_active and self._model.document.is_active:
new_input, job_params = self._model._prepare_live_workflow()
if self._last_input != new_input:
now = time.monotonic()
if self._last_change + settings.live_redraw_grace_period <= now:
await self._model._generate_live(new_input, job_params)
self._last_input = new_input
return
else:
self._last_change = time.monotonic()
while self.is_active:
if self._model.document.is_active:
new_input, job_params = self._model._prepare_live_workflow()
if self._last_input != new_input:
now = time.monotonic()
if self._last_change + settings.live_redraw_grace_period <= now:
await self._model._generate_live(new_input, job_params)
self._last_input = new_input
return
else:
self._last_change = time.monotonic()
await asyncio.sleep(self._poll_rate)

def apply_result(self, layer_only=False):
Expand Down

0 comments on commit 98e64d8

Please sign in to comment.