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

Add asynchronous task support to worker threads #7880

Closed
wants to merge 3 commits into from

Conversation

zanieb
Copy link
Contributor

@zanieb zanieb commented Dec 14, 2022

Follow-up to #7875

Adds support for submission and execution of coroutine functions to the worker pool.

Example

import asyncio
from prefect._internal.concurrency.workers import WorkerThreadPool

async def aidentity(x):
    await asyncio.sleep(0)
    return x

async def main():
    pool = WorkerThreadPool()
    future = await pool.submit(aidentity, 1)
    print(await future.aresult())

asyncio.run(main())

Checklist

  • This pull request references any related issue by including "closes <link to issue>"
    • If no issue exists and your change is not a small fix, please create an issue first.
  • This pull request includes tests or only affects documentation.
  • This pull request includes a label categorizing the change e.g. fix, feature, enhancement

@zanieb zanieb added the development Tech debt, refactors, CI, tests, and other related work. label Dec 14, 2022
@zanieb zanieb force-pushed the engine/worker-async branch 2 times, most recently from 7a8de46 to 63c9a6b Compare December 14, 2022 16:40
Base automatically changed from engine/worker to main December 15, 2022 15:51
@zanieb zanieb force-pushed the engine/worker-async branch from 63c9a6b to d71a702 Compare December 15, 2022 15:53
@zanieb zanieb marked this pull request as ready for review December 15, 2022 15:53
@netlify
Copy link

netlify bot commented Dec 15, 2022

Deploy Preview for prefect-orion ready!

Name Link
🔨 Latest commit b9c29e8
🔍 Latest deploy log https://app.netlify.com/sites/prefect-orion/deploys/639b5f1b7ef8350008c2662c
😎 Deploy Preview https://deploy-preview-7880--prefect-orion.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
development Tech debt, refactors, CI, tests, and other related work.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant