Skip to content

Fix Python 3.11+ crash in EquinixMetal list_resources_async - #2218

Open
Hisernberg wants to merge 2 commits into
apache:trunkfrom
Hisernberg:fix/equinixmetal-async-py311
Open

Hisernberg wants to merge 2 commits into
apache:trunkfrom
Hisernberg:fix/equinixmetal-async-py311

Conversation

@Hisernberg

Copy link
Copy Markdown
Contributor

list_resources_async built _list_async via exec() using @asyncio.coroutine and yield from — both removed in Python 3.11 — so any call raises:

AttributeError: module 'asyncio' has no attribute 'coroutine'

(verified by running the same exec snippet on 3.12). The code comment already says the exec existed only to avoid a Python 2 SyntaxError from yield from, and Python 2 support is long gone.

Replaced with a plain async def _list_async() + await. Semantics preserved: one executor job per project, results concatenated in project order (same as before).

Python 3.12 deprecates datetime.utcnow(). All 9 call sites now use
datetime.now(timezone.utc).replace(tzinfo=None):

- identical naive-UTC values for every consumer (SigV4/SAS signing,
  X-*-Date headers, token-expiry arithmetic)
- GoogleBaseConnection._utcnow() stays naive so the existing
  GoogleTestCase mock and the token-expiry comparisons keep working
- utctimetuple() rendering in openstack_identity unchanged
The exec() crutch used @asyncio.coroutine and 'yield from', both removed
in Python 3.11, so every call raised AttributeError: module 'asyncio'
has no attribute 'coroutine' (verified). The comment itself says the
exec existed only for Python 2 SyntaxError avoidance; replaced with a
plain async method. Semantics preserved: executor threads per project,
results concatenated in project order.
@micafer

micafer commented Nov 13, 2026

Copy link
Copy Markdown
Contributor

It looks like the first commit (262f80d) contains unrelated changes that have already been merged into trunk.
Could you please rebase this branch onto the latest trunk and drop the unrelated commit, so the PR only contains the changes relevant to this fix?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants