Skip to content

Commit

Permalink
Import UTC the old way for compatibility with older versions
Browse files Browse the repository at this point in the history
  • Loading branch information
jacopofar committed Mar 26, 2024
1 parent f931686 commit d9a05d8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 13 deletions.
12 changes: 5 additions & 7 deletions postgrestq/task_queue.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
import json
import logging
from datetime import datetime
try:
# supported only from 3.11 onwards
from datetime import UTC
except ImportError:
from datetime import timezone
UTC = timezone.utc


from uuid import uuid4, UUID
from typing import Optional, Tuple, Iterator, Dict, Any, Callable

from psycopg import sql, connect

# supported only from 3.11 onwards:
# from datetime import UTC
# workaround for older versions:
from datetime import timezone
UTC = timezone.utc

logger = logging.getLogger(__name__)

Expand Down
12 changes: 6 additions & 6 deletions tests/test_task_queue.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
from datetime import datetime, timedelta
try:
# supported only from 3.11 onwards
from datetime import UTC
except ImportError:
from datetime import timezone
UTC = timezone.utc
# supported only from 3.11 onwards:
# from datetime import UTC
# workaround for older versions:
from datetime import timezone
UTC = timezone.utc

import logging
import time
import os
Expand Down

0 comments on commit d9a05d8

Please sign in to comment.