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

feat: add python runtime and plugin #3181

Merged
merged 2 commits into from
Oct 25, 2024
Merged

Conversation

wesbillman
Copy link
Member

No description provided.

This was referenced Oct 24, 2024
@@ -103,7 +103,7 @@ func generateStubsForEachLanguage(ctx context.Context, projectRoot string, modul
}
err := wg.Wait()
if err != nil {
return fmt.Errorf("failed to generate go stubs: %w", err)
return fmt.Errorf("failed to generate language stubs: %w", err)
Copy link
Contributor

Choose a reason for hiding this comment

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

🫡

@worstell worstell marked this pull request as ready for review October 25, 2024 00:21
@worstell worstell requested review from a team and alecthomas as code owners October 25, 2024 00:21
@worstell worstell requested review from safeer and removed request for a team October 25, 2024 00:21
@worstell worstell force-pushed the add-python-runtime-and-plugin branch from 37c6b67 to ce1d013 Compare October 25, 2024 00:24
@worstell worstell force-pushed the add-python-runtime-and-plugin branch from 68e3158 to adc1285 Compare October 25, 2024 00:37
@wesbillman wesbillman force-pushed the add-python-runtime-and-plugin branch 3 times, most recently from dd4fb2d to dcedd97 Compare October 25, 2024 00:57
Copy link
Collaborator

@alecthomas alecthomas left a comment

Choose a reason for hiding this comment

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

We'll also need to add Python to the ftl-runner Docker image.

@@ -0,0 +1,58 @@
package main
Copy link
Collaborator

Choose a reason for hiding this comment

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

This should be in python-runtime/cmd/ftl-language-python/main.go

Comment on lines +34 to +57
logger.Infof("ftl-language-python starting up")

// Handle signals.
sigch := make(chan os.Signal, 1)
signal.Notify(sigch, syscall.SIGINT, syscall.SIGTERM)
go func() {
sig := <-sigch
logger.Debugf("ftl-language-python terminating with signal %s", sig)
cancel()
_ = syscall.Kill(-syscall.Getpid(), sig.(syscall.Signal)) //nolint:forcetypeassert,errcheck // best effort
os.Exit(0)
}()

kctx.BindTo(ctx, (*context.Context)(nil))

svc := pythonplugin.New()
logger.Infof("ftl-language-python starting to serve on %v", cli.Bind)
err := rpc.Serve(ctx,
cli.Bind,
rpc.GRPC(languagepbconnect.NewLanguageServiceHandler, svc),
rpc.PProf(),
)
logger.Errorf(err, "ftl-language-python stopped serving")
kctx.FatalIfErrorf(err)
Copy link
Collaborator

Choose a reason for hiding this comment

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

This should be using internal/plugin.Start(), which handles all this for you automatically.

Copy link
Member Author

Choose a reason for hiding this comment

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

Awesome! I'll check with @matt2e too and we can update the goplugin branch as well. Thanks!

Copy link
Member Author

Choose a reason for hiding this comment

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

@wesbillman wesbillman merged commit 20cb161 into main Oct 25, 2024
96 checks passed
@wesbillman wesbillman deleted the add-python-runtime-and-plugin branch October 25, 2024 01:27
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.

4 participants