Skip to content

Commit

Permalink
Remove junk sqs implementation and requirements for utc param in stor…
Browse files Browse the repository at this point in the history
…age.
  • Loading branch information
coleifer committed Jul 17, 2024
1 parent 0b6722a commit 46a34cb
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 187 deletions.
2 changes: 1 addition & 1 deletion huey/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -594,7 +594,7 @@ def is_revoked(self, task, timestamp=None, peek=True):
def add_schedule(self, task):
data = self.serialize_task(task)
eta = task.eta or datetime.datetime.fromtimestamp(0)
self.storage.add_to_schedule(data, eta, self.utc)
self.storage.add_to_schedule(data, eta)
logger.info('Added task %s to schedule, eta %s', task.id, eta)
self._emit(S.SIGNAL_SCHEDULED, task)

Expand Down
2 changes: 1 addition & 1 deletion huey/contrib/kyototycoon.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def flush_queue(self):
def convert_ts(self, ts):
return int(time.mktime(ts.timetuple()))

def add_to_schedule(self, data, ts, utc):
def add_to_schedule(self, data, ts):
self.s.add(data, self.convert_ts(ts))

def read_schedule(self, ts):
Expand Down
2 changes: 1 addition & 1 deletion huey/contrib/sql_huey.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ def enqueued_items(self, limit=None):
def flush_queue(self):
self.Task.delete().where(self.Task.queue == self.name).execute()

def add_to_schedule(self, data, timestamp, utc):
def add_to_schedule(self, data, timestamp):
self.check_conn()
self.Schedule.create(queue=self.name, data=data, timestamp=timestamp)

Expand Down
176 changes: 0 additions & 176 deletions huey/contrib/sqs.py

This file was deleted.

13 changes: 6 additions & 7 deletions huey/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,14 +100,13 @@ def flush_queue(self):
"""
raise NotImplementedError

def add_to_schedule(self, data, ts, utc):
def add_to_schedule(self, data, ts):
"""
Add the given task data to the schedule, to be executed at the given
timestamp.
:param bytes data: Task data.
:param datetime ts: Timestamp at which task should be executed.
:param bool utc: Whether huey is in UTC-mode or local mode.
:return: No return value.
"""
raise NotImplementedError
Expand Down Expand Up @@ -247,7 +246,7 @@ def dequeue(self): pass
def queue_size(self): return 0
def enqueued_items(self, limit=None): return []
def flush_queue(self): pass
def add_to_schedule(self, data, ts, utc): pass
def add_to_schedule(self, data, ts): pass
def read_schedule(self, ts): return []
def schedule_size(self): return 0
def scheduled_items(self, limit=None): return []
Expand Down Expand Up @@ -296,7 +295,7 @@ def enqueued_items(self, limit=None):
def flush_queue(self):
self._queue = []

def add_to_schedule(self, data, ts, utc):
def add_to_schedule(self, data, ts):
heapq.heappush(self._schedule, (ts, data))

def read_schedule(self, ts):
Expand Down Expand Up @@ -438,7 +437,7 @@ def enqueued_items(self, limit=None):
def flush_queue(self):
self.conn.delete(self.queue_key)

def add_to_schedule(self, data, ts, utc):
def add_to_schedule(self, data, ts):
self.conn.zadd(self.schedule_key, {data: self.convert_ts(ts)})

def read_schedule(self, ts):
Expand Down Expand Up @@ -753,7 +752,7 @@ def enqueued_items(self, limit=None):
def flush_queue(self):
self.sql('delete from task where queue=?', (self.name,), commit=True)

def add_to_schedule(self, data, ts, utc):
def add_to_schedule(self, data, ts):
params = (self.name, to_blob(data), to_timestamp(ts))
self.sql('insert into schedule (queue, data, timestamp) '
'values (?, ?, ?)', params, commit=True)
Expand Down Expand Up @@ -937,7 +936,7 @@ def _timestamp_to_prefix(self, ts):
ts = time.mktime(ts.timetuple()) + (ts.microsecond * 1e-6)
return '%012x' % int(ts * 1000)

def add_to_schedule(self, data, ts, utc):
def add_to_schedule(self, data, ts):
with self.lock:
if not os.path.exists(self.schedule_path):
os.makedirs(self.schedule_path)
Expand Down
2 changes: 1 addition & 1 deletion huey/tests/test_storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def test_schedule_methods(self):
(b'n1', timestamp - second),
(b'p2', timestamp + second + second))
for data, ts in items:
self.s.add_to_schedule(data, ts, False)
self.s.add_to_schedule(data, ts)

self.assertEqual(self.s.schedule_size(), 4)

Expand Down

0 comments on commit 46a34cb

Please sign in to comment.