fix: update Workflows wrapper to work more natively with Python objects#138
Conversation
|
Now I have a comprehensive understanding of the changes. Let me assess any actionable issues:
Let me check one more thing — whether Actually, wait — I notice a subtle issue in async def _poll_until_settled(instance, timeout=20.0):
elapsed = 0.0
interval = 0.1
status = await instance.status() # <-- First poll, before the loop
while elapsed < timeout:
if status["status"] not in ("queued", "running"):
return status
await asyncio.sleep(interval)
elapsed += interval
status = await instance.status()
return status # <-- Returns last status even if not settledThis is fine — the function polls, sleeps, polls again. If timeout is exceeded, it returns the last status (leaving it to the caller to decide what to do). The caller at line 83-84 handles this correctly by asserting Overall, this is a clean, well-tested change. The core logic changes are:
I don't see any actionable logic bugs, security issues, backward compat violations, or missing edge cases. The tests cover both the new native Python object path and the legacy LGTM |
dom96
left a comment
There was a problem hiding this comment.
Looks good to me, but would like @Caio-Nogueira to take a look as well.
|
Yeah LGTM, as long as it doesn't break backwards compatibility with current callers that explicitly use |
Another bindings update. This update the existing Workflow wrapper classes to take and return native Python objects, so that users does not have to use
to_jsexplicitly.Context for workflows team: We are updating Python workers SDK so that users does not have to user pyodide FFIs at all, and use the native Python objects directly. After this update, we can remove all the
to_jsusage in workflows docs (https://developers.cloudflare.com/workflows/python/bindings/)