Skip to content

Commit

Permalink
[EventEngine] Disable EventEngine polling in gRPC Python (grpc#33279)
Browse files Browse the repository at this point in the history
This is a hack to get around an issue on Apple devices caused by the
PosixEventEngine's `poll` poller not supporting fork. This PR disables
the EventEngine poller entirely in Python builds. It will therefore
prevent the release of the EventEngine generally, and prevent any
testing of EventEngine integration with gRPC Python, until the `poll`
poller is fixed.
  • Loading branch information
drfloob authored May 31, 2023
1 parent 10001d1 commit 3225a9f
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 1 deletion.
2 changes: 2 additions & 0 deletions bazel/cython_library.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,15 @@ def pyx_library(name, deps = [], py_deps = [], srcs = [], **kwargs):
)

shared_objects = []
defines = kwargs.pop("defines", [])
for src in pyx_srcs:
stem = src.split(".")[0]
shared_object_name = stem + ".so"
native.cc_binary(
name = shared_object_name,
srcs = [stem + ".cpp"],
deps = deps + ["@local_config_python//:python_headers"],
defines = defines,
linkshared = 1,
)
shared_objects.append(shared_object_name)
Expand Down
4 changes: 4 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,10 @@ def _quote_build_define(argument):
('GRPC_ENABLE_FORK_SUPPORT', 1),
)

# Fix for multiprocessing support on Apple devices.
# TODO(vigneshbabu): Remove this once the poll poller gets fork support.
DEFINE_MACROS += (('GRPC_DO_NOT_INSTANTIATE_POSIX_POLLER', 1),)

LDFLAGS = tuple(EXTRA_LINK_ARGS)
CFLAGS = tuple(EXTRA_COMPILE_ARGS)
if "linux" in sys.platform or "darwin" in sys.platform:
Expand Down
3 changes: 2 additions & 1 deletion src/core/lib/event_engine/posix_engine/posix_engine.cc
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@

// TODO(eryu): remove this GRPC_CFSTREAM condition when the CFEngine is ready.
// The posix poller currently crashes iOS.
#if defined(GRPC_POSIX_SOCKET_TCP) && !defined(GRPC_CFSTREAM)
#if defined(GRPC_POSIX_SOCKET_TCP) && !defined(GRPC_CFSTREAM) && \
!defined(GRPC_DO_NOT_INSTANTIATE_POSIX_POLLER)
#define GRPC_PLATFORM_SUPPORTS_POSIX_POLLING true
#else
#define GRPC_PLATFORM_SUPPORTS_POSIX_POLLING false
Expand Down
1 change: 1 addition & 0 deletions src/python/grpcio/grpc/_cython/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ pyx_library(
"cygrpc.pyx",
],
data = [":copy_roots_pem"],
defines = ["GRPC_DO_NOT_INSTANTIATE_POSIX_POLLER=1"],
deps = [
"//:grpc",
],
Expand Down

0 comments on commit 3225a9f

Please sign in to comment.