]> git.0d.be Git - django-panik-nonstop.git/commitdiff
stamina: recompute now() in main loop
authorFrédéric Péters <fpeters@0d.be>
Wed, 15 Jul 2020 20:16:52 +0000 (22:16 +0200)
committerFrédéric Péters <fpeters@0d.be>
Wed, 15 Jul 2020 20:16:52 +0000 (22:16 +0200)
nonstop/management/commands/stamina.py

index ae59c0256aca0a295f5d76c3118601ec2ec1b0e1..d80bace4dbbabbcc9e01f1ecb8ea622a2d2e46b6 100644 (file)
@@ -413,7 +413,6 @@ class Command(BaseCommand):
         loop.add_signal_handler(
                 signal.SIGTERM,
                 self.sigterm_handler)
-        now = datetime.datetime.now()
         self.recompute_slots()
         server = await asyncio.start_server(
                 self.handle_connection,
@@ -424,6 +423,7 @@ class Command(BaseCommand):
 
             self.recompute_slots_task = asyncio.create_task(self.recompute_slots_loop())
             while not self.quit:
+                now = datetime.datetime.now()
                 duration = (self.slot.end_datetime - now).seconds
                 logger.debug('Next sure shot %s (in %s)', self.slot.end_datetime, duration)
                 if duration < 2: