from django.core.management.base import BaseCommand, CommandError
from ...models import Render


class Command(BaseCommand):
    help = 'Deletes output of all expired renders'

    def handle(self, *args, **options):
        for render in Render.objects.expired().iterator():
            try:
                render.delete_output()
            except FileNotFoundError:
                print(f"❌  Render {render.id} already deleted")
            else:
                print(f"✅  Render {render.id} deleted")


from django.core.management.base import BaseCommand, CommandError
from ...models import Render


class Command(BaseCommand):
    help = 'Deletes output of all expired renders'

    def handle(self, *args, **options):
        for render in Render.objects.expired().iterator():
            try:
                render.delete_output()
            except FileNotFoundError:
                print(f"❌  Render {render.id} already deleted", flush=True)
            else:
                print(f"✅  Render {render.id} deleted", flush=True)


Add flush to delete all renders print
Add flush to delete all renders print

  from django.core.management.base import BaseCommand, CommandError
  from ...models import Render
  
  
  class Command(BaseCommand):
      help = 'Deletes output of all expired renders'
  
      def handle(self, *args, **options):
          for render in Render.objects.expired().iterator():
              try:
                  render.delete_output()
              except FileNotFoundError:
-                 print(f"❌  Render {render.id} already deleted")
+                 print(f"❌  Render {render.id} already deleted", flush=True)
              else:
-                 print(f"✅  Render {render.id} deleted")
+                 print(f"✅  Render {render.id} deleted", flush=True)
  
  
Add flush to delete all renders print
## Code Before:
from django.core.management.base import BaseCommand, CommandError
from ...models import Render


class Command(BaseCommand):
    help = 'Deletes output of all expired renders'

    def handle(self, *args, **options):
        for render in Render.objects.expired().iterator():
            try:
                render.delete_output()
            except FileNotFoundError:
                print(f"❌  Render {render.id} already deleted")
            else:
                print(f"✅  Render {render.id} deleted")


## Instruction:
Add flush to delete all renders print
## Code After:
from django.core.management.base import BaseCommand, CommandError
from ...models import Render


class Command(BaseCommand):
    help = 'Deletes output of all expired renders'

    def handle(self, *args, **options):
        for render in Render.objects.expired().iterator():
            try:
                render.delete_output()
            except FileNotFoundError:
                print(f"❌  Render {render.id} already deleted", flush=True)
            else:
                print(f"✅  Render {render.id} deleted", flush=True)

