Skip to content

Python multiprocessing example starts gRPC servers before forking all processes #40904

@chimaerase

Description

@chimaerase

What did you expect to see?

The Python multiprocessing server.py example states "It is imperative that the worker subprocesses be forked before any gRPC servers start up. See #16001 for more details." However, it starts each worker process immediately after creating it, with no barrier in _run_server() to calling server.start(). From inspection, this seems likely to create a race condition where some servers may be started before all processes are forked.

It seems safer to, e.g. add a multiprocessing.Barrier parameter to _run_server() and call barrier.wait() at the start of the function to ensure no gRPC server can be started before all the processes are forked.

What did you see instead?

Make sure you include information that can help us debug (full error message, exception listing, stack trace, logs).

See TROUBLESHOOTING.md for how to diagnose problems better.

Anything else we should know about your project / environment?

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions