Skip to content
This repository was archived by the owner on Mar 26, 2025. It is now read-only.

Conversation

@mrkaye97
Copy link
Contributor

Couple things:

  1. Adding sync versions of spawn_workflow and spawn_workflows on the context since a few people have asked about that
  2. Puts in an attempt at a fix for sync_result - it was pretty buried, but basically it was hanging for two reasons. One is that the PooledWorkflowRunListener wasn't being initialized correctly if no loop was running, because the workflow listener needs an async gRPC connection but we were trying to create one with no loop running. Then the other issue was that run_coroutine_threadsafe wasn't actually doing what we want - we need run_until_complete instead

This is definitely a bit of a case of "it worked on my local", but it should at least be less broken than the current state of affairs

@mrkaye97 mrkaye97 requested a review from abelanger5 February 14, 2025 21:43
Comment on lines -37 to +46
with EventLoopThread() as loop:
coro = self.workflow_listener.result(self.workflow_run_id)
future = asyncio.run_coroutine_threadsafe(coro, loop)
return future.result()
loop = asyncio.new_event_loop()
asyncio.set_event_loop(loop)
try:
return loop.run_until_complete(coro)
finally:
asyncio.set_event_loop(None)
else:
coro = self.workflow_listener.result(self.workflow_run_id)
future = asyncio.run_coroutine_threadsafe(coro, loop)
return future.result()
return loop.run_until_complete(coro)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not 100% sure this is safe, but I think the only risk of it causing issues is if there's no event loop, which I can't imagine being super common. It's a little tough to test well though

@mrkaye97 mrkaye97 changed the base branch from main to feat--0.47 February 18, 2025 15:35
@mrkaye97 mrkaye97 merged commit 88a28ba into feat--0.47 Feb 18, 2025
6 checks passed
@mrkaye97 mrkaye97 deleted the feat--add-sync-spawn-methods branch February 18, 2025 15:35
@mrkaye97 mrkaye97 mentioned this pull request Feb 18, 2025
mrkaye97 added a commit that referenced this pull request Feb 19, 2025
* Fix: More OTel Cleanup (#319)

* feat: factor our helpers

* chore: bump version

* fix: replace none-default

* fix: auto-create parent

* feat: docs

* fix: doc format

* fix: example

* feat: use global tracer if none provided

* fix: docs

* Fix: Bump min `celpy` version (#320)

* fix: bump min celpy version

* chore: ver

* Feat: Sync spawn methods + fixing `sync_result` (#321)

* feat: add sync spawn method

* feat: example

* fix: sync workflow run + sync_result

* fix: examples

* fix: lint

* feat: bulk spawn

* chore: ver

* fix: test

* fix: lint

* Feat: Killing sync threads (#323)

* feat: thread killing

* fix: rm events

* fix: lint

* fix: cruft

* fix: async sleep

* feat: flag for enabling force killing threads
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants