From 096c9e07cb1623f52b840d3d9157fb4859669d9a Mon Sep 17 00:00:00 2001 From: Wilfred Tyler Gee Date: Fri, 17 Nov 2023 09:39:28 -1000 Subject: [PATCH] Adding a small time delay. This appears to be a race condition with setting the sequence_id too quickly. --- src/panoptes/pocs/scheduler/scheduler.py | 3 +-- tests/scheduler/test_dispatch_scheduler.py | 15 +++++++++------ 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/panoptes/pocs/scheduler/scheduler.py b/src/panoptes/pocs/scheduler/scheduler.py index fcfa47174..8f6732dec 100644 --- a/src/panoptes/pocs/scheduler/scheduler.py +++ b/src/panoptes/pocs/scheduler/scheduler.py @@ -7,7 +7,6 @@ from astropy import units as u from astropy.coordinates import get_body from panoptes.utils import error -from panoptes.utils.library import load_module from panoptes.utils.serializers import from_yaml from panoptes.utils.time import current_time @@ -121,7 +120,7 @@ def current_observation(self, new_observation): # Add the new observation to the list self.observed_list[new_observation.seq_time] = new_observation - self.logger.info("Setting new observation to {}".format(new_observation)) + self.logger.info(f'Setting new observation to {new_observation}') self._current_observation = new_observation @property diff --git a/tests/scheduler/test_dispatch_scheduler.py b/tests/scheduler/test_dispatch_scheduler.py index fdf9013f8..01bdd6c40 100644 --- a/tests/scheduler/test_dispatch_scheduler.py +++ b/tests/scheduler/test_dispatch_scheduler.py @@ -1,6 +1,7 @@ import os import yaml import pytest +import time from astropy import units as u from astropy.coordinates import EarthLocation @@ -245,18 +246,20 @@ def test_new_observation_seq_time(scheduler): def test_observed_list(scheduler): assert len(scheduler.observed_list) == 0 - time = Time('2016-09-11 07:08:00') - scheduler.get_observation(time=time) + time0 = Time('2016-09-11 07:08:00') + scheduler.get_observation(time=time0) assert len(scheduler.observed_list) == 1 # A few hours later should now be different - time = Time('2016-09-11 10:08:00') - scheduler.get_observation(time=time) + time.sleep(1) + time1 = Time('2016-09-11 10:08:00') + scheduler.get_observation(time=time1) assert len(scheduler.observed_list) == 2 # A few hours later should be the same - time = Time('2016-09-11 14:38:00') - scheduler.get_observation(time=time) + time.sleep(1) + time2 = Time('2016-09-11 14:38:00') + scheduler.get_observation(time=time2) assert len(scheduler.observed_list) == 2 scheduler.reset_observed_list()