Skip to content

Commit

Permalink
fix python 3.9 compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
gpetretto committed Nov 8, 2024
1 parent 685f012 commit fa406db
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
10 changes: 8 additions & 2 deletions src/jobflow_remote/jobs/jobcontroller.py
Original file line number Diff line number Diff line change
Expand Up @@ -3881,8 +3881,14 @@ def lock_job_for_update(
no_retry = True
except RemoteError as e:
error = f"Remote error: {e.msg}"
if e.__cause__:
trace = traceback.format_exception(e.__cause__)
cause = e.__cause__
if cause:
# this is required for support of python 3.9. In 3.10 the API
# changed and format_exception(e) could be used instead.
# Do that if/when support for 3.9 is dropped.
trace = traceback.format_exception(
type(cause), cause, cause.__traceback__
)
error += "\ncaused by:\n" + "".join(trace)
no_retry = e.no_retry
except Exception:
Expand Down
2 changes: 1 addition & 1 deletion tests/db/utils/test_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def test_get_past_time_rounded():
def test_get_utc_offset():
from jobflow_remote.utils.data import get_utc_offset

assert get_utc_offset("America/Los_Angeles") == "-07:00"
assert get_utc_offset("America/Buenos_Aires") == "-03:00"
assert get_utc_offset("Europe/Moscow") == "+03:00"
assert get_utc_offset("UTC") == "+00:00"
assert get_utc_offset("Asia/Shanghai") == "+08:00"
Expand Down

0 comments on commit fa406db

Please sign in to comment.