Skip to content

Commit

Permalink
Adding a small time delay. This appears to be a race condition with s…
Browse files Browse the repository at this point in the history
…etting the sequence_id too quickly.
  • Loading branch information
wtgee committed Nov 17, 2023
1 parent 31e40a1 commit 096c9e0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
3 changes: 1 addition & 2 deletions src/panoptes/pocs/scheduler/scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down
15 changes: 9 additions & 6 deletions tests/scheduler/test_dispatch_scheduler.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import os
import yaml
import pytest
import time

from astropy import units as u
from astropy.coordinates import EarthLocation
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit 096c9e0

Please sign in to comment.