Commit 772f2841 authored by Michael Fladischer's avatar Michael Fladischer

Pick upstream patch to fix solar based scheduler.

parent 719f895d
celery (4.1.0-2) UNRELEASED; urgency=medium
* Add python(3)-ephem to Depends to allow for solar based schedules.
* Pick upstream patch to fix solar based scheduler.
-- Michael Fladischer <fladi@debian.org> Mon, 13 Nov 2017 22:18:00 +0100
......
From: DDevine <devine@ddevnet.net>
Date: Wed, 26 Jul 2017 18:19:03 +1000
Subject: Fixed exception caused by next_transit receiving an unexpected
argument. (#4103)
* Fixed exception caused by next_transit receiving an unexpected argument.
* Fixing inconsistent style.
* Adding tests for solar methods to determine if they accept the use_center argument or not.
* Fixing flake8 errors.
---
celery/schedules.py | 16 +++++++++++-----
t/unit/app/test_schedules.py | 11 +++++++++++
2 files changed, 22 insertions(+), 5 deletions(-)
diff --git a/celery/schedules.py b/celery/schedules.py
index eefe111..8624d39 100644
--- a/celery/schedules.py
+++ b/celery/schedules.py
@@ -728,7 +728,7 @@ class solar(BaseSchedule):
'dawn_nautical': True,
'dawn_civil': True,
'sunrise': False,
- 'solar_noon': True,
+ 'solar_noon': False,
'sunset': False,
'dusk_civil': True,
'dusk_nautical': True,
@@ -783,10 +783,16 @@ class solar(BaseSchedule):
last_run_at_utc = localize(last_run_at, timezone.utc)
self.cal.date = last_run_at_utc
try:
- next_utc = getattr(self.cal, self.method)(
- self.ephem.Sun(),
- start=last_run_at_utc, use_center=self.use_center,
- )
+ if self.use_center:
+ next_utc = getattr(self.cal, self.method)(
+ self.ephem.Sun(),
+ start=last_run_at_utc, use_center=self.use_center
+ )
+ else:
+ next_utc = getattr(self.cal, self.method)(
+ self.ephem.Sun(), start=last_run_at_utc
+ )
+
except self.ephem.CircumpolarError: # pragma: no cover
# Sun won't rise/set today. Check again tomorrow
# (specifically, after the next anti-transit).
diff --git a/t/unit/app/test_schedules.py b/t/unit/app/test_schedules.py
index 6732047..f3a55fe 100644
--- a/t/unit/app/test_schedules.py
+++ b/t/unit/app/test_schedules.py
@@ -74,6 +74,17 @@ class test_solar:
with pytest.raises(ValueError):
solar('asdqwewqew', 60, 60, app=self.app)
+ def test_event_uses_center(self):
+ s = solar('solar_noon', 60, 60, app=self.app)
+ for ev, is_center in s._use_center_l.items():
+ s.method = s._methods[ev]
+ s.is_center = s._use_center_l[ev]
+ try:
+ s.remaining_estimate(datetime.utcnow())
+ except TypeError:
+ pytest.fail("{0} was called with 'use_center' which is not a \
+ valid keyword for the function.".format(s.method))
+
class test_schedule:
......@@ -2,3 +2,4 @@ lsb-init.patch
privacy.patch
0007-Set-shell-in-su-invocation.patch
0004-Disable-intershpinx-mapping-for-now.patch
0005-Fixed-exception-caused-by-next_transit-receiving-an-.patch
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment