Skip to content
This repository has been archived by the owner on Aug 3, 2023. It is now read-only.

Commit

Permalink
Fix Python 2.7 compatibility.
Browse files Browse the repository at this point in the history
  • Loading branch information
mossblaser committed Jul 18, 2016
1 parent a297897 commit 8c401b3
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions spalloc_server/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

import time

from datetime import datetime, timedelta
from datetime import datetime

from pytz import utc

Expand Down Expand Up @@ -1228,7 +1228,7 @@ def __init__(self, id, owner,
else:
now = datetime.now(utc)
epoch = datetime(1970, 1, 1, tzinfo=utc)
self.start_time = (now - epoch) / timedelta(seconds=1)
self.start_time = (now - epoch).total_seconds()

# If None, never kill this job due to inactivity. Otherwise, stop the
# job if the time exceeds this value. It is the allocator's
Expand Down
4 changes: 2 additions & 2 deletions tests/test_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import time

from datetime import datetime, timedelta
from datetime import datetime

from pytz import utc

Expand Down Expand Up @@ -647,7 +647,7 @@ def test_list_jobs(conn, m):

now = datetime.now(utc)
epoch = datetime(1970, 1, 1, tzinfo=utc)
unixtime_now = (now - epoch) / timedelta(seconds=1)
unixtime_now = (now - epoch).total_seconds()
assert unixtime_now - 1.0 <= jobs[0].start_time <= unixtime_now
assert unixtime_now - 1.0 <= jobs[1].start_time <= unixtime_now

Expand Down

0 comments on commit 8c401b3

Please sign in to comment.