Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update datetime.utcnow() to use UTC timezone-aware object #302

Merged
merged 3 commits into from
Nov 5, 2024

Conversation

lebaudantoine
Copy link
Contributor

@lebaudantoine lebaudantoine commented Nov 3, 2024

Following deprecation warning was raised:

  /usr/local/lib/python3.12/site-packages/livekit/api/access_token.py:152: DeprecationWarning: datetime.datetime.utcnow() is deprecated and scheduled for removal in a future version. Use timezone-aware objects to represent datetimes in UTC: datetime.datetime.now(datetime.UTC).
    (datetime.datetime.utcnow() + self.ttl).utctimetuple()

datetime.utcnow() is being deprecated in Python 3.12 as it returns a naive datetime object without timezone information. Replace with datetime.now(UTC) to use an explicit timezone-aware object, preventing potential timezone ambiguity issues.

In access_token.py, updated the token expiration calculation to use the recommended timezone-aware approach.

datetime.utcnow() is being deprecated in Python 3.12 as it returns a naive
datetime object without timezone information. Replace with datetime.now(UTC)
to use an explicit timezone-aware object, preventing potential timezone
ambiguity issues.

In access_token.py, updated the token expiration calculation to use the
recommended timezone-aware approach.
@lebaudantoine lebaudantoine marked this pull request as ready for review November 3, 2024 16:05
Copy link
Member

@davidzhao davidzhao left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@davidzhao
Copy link
Member

thanks for the fix!

@davidzhao davidzhao merged commit 6ea5452 into livekit:main Nov 5, 2024
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants