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

Load flows for deployments in a worker thread #6340

Merged
merged 1 commit into from
Aug 11, 2022
Merged

Load flows for deployments in a worker thread #6340

merged 1 commit into from
Aug 11, 2022

Conversation

zanieb
Copy link
Contributor

@zanieb zanieb commented Aug 9, 2022

Summary

If not run in a worker thread, the user's code is executed in an "async" context which means that any methods decorated by sync_compatible will return a coroutine. However, top-level code in a script is always intended to be run in a "sync" context, so the user can never await the coroutines and code that works without a deployment will break while using a deployment.

Steps Taken to QA Changes

Needs QA and unit test

Checklist

This pull request is:

  • A documentation / typographical error fix
    • No tests or issue needed
  • A short code fix
    • Please reference the related issue by including "closes <link to issue>" in this Pull Request's summary section.
      • If no issue exists, please create a bug report issue
    • Please include tests. One-line fixes without tests will not be accepted unless it's related to the documentation only.
  • A new feature implementation
    • Please reference the related issue by including "closes <link to issue>" in this Pull Request's summary section.
      • If no issue exists, please create a feature enhancement issue
    • Please include tests
    • Please make sure that your QA steps are both thorough and easy to reproduce by somebody with limited knowledge of the feature that you are submitting

Happy engineering!

If not run in a worker thread, it is executed in an "async" context which means that any methods decorated by `sync_compatible` will return a coroutine. However, top-level code in a script is always intended to be run in a "sync" context, so the user can never `await` the coroutines and code that works without a deployment will break while using a deployment.
@zanieb zanieb requested a review from cicdw as a code owner August 9, 2022 21:31
Copy link
Member

@cicdw cicdw left a comment

Choose a reason for hiding this comment

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

interesting - very good detective work

@zanieb
Copy link
Contributor Author

zanieb commented Aug 9, 2022

Thanks! Yeah we need to be careful about performing synchronous IO from asynchronous contexts in general, but it's even more important when it could execute code.

It looks like there are not any isolated tests for load_flow_from_flow_run yet. Are those in progress somewhere?

@zanieb zanieb merged commit fe06be9 into main Aug 11, 2022
@zanieb zanieb deleted the fix-sync-load branch August 11, 2022 16:51
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