diff options
author | Eric Gribkoff <ericgribkoff@google.com> | 2018-08-20 23:00:02 -0700 |
---|---|---|
committer | Eric Gribkoff <ericgribkoff@google.com> | 2018-08-23 09:40:39 -0700 |
commit | acc020caf77240f7504af9c2c1ea5a0dac1884d6 (patch) | |
tree | e516cb3947e1e96372599fd02e727d373c465c7d /src/python/grpcio/grpc/_cython/_cygrpc/fork_posix.pyx.pxi | |
parent | 77b713324494e183da2bb458f072b0b5f0fb45a5 (diff) |
Support tracking and closing fds post-fork in ev_poll_posix
This extends gRPC Python's fork compatibility to Mac OS, which does not support
epoll
The changes are a no-op if fork support is disabled
Diffstat (limited to 'src/python/grpcio/grpc/_cython/_cygrpc/fork_posix.pyx.pxi')
-rw-r--r-- | src/python/grpcio/grpc/_cython/_cygrpc/fork_posix.pyx.pxi | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/python/grpcio/grpc/_cython/_cygrpc/fork_posix.pyx.pxi b/src/python/grpcio/grpc/_cython/_cygrpc/fork_posix.pyx.pxi index 0d2516977b..303bcd976c 100644 --- a/src/python/grpcio/grpc/_cython/_cygrpc/fork_posix.pyx.pxi +++ b/src/python/grpcio/grpc/_cython/_cygrpc/fork_posix.pyx.pxi @@ -23,6 +23,8 @@ _AWAIT_THREADS_TIMEOUT_SECONDS = 5 _TRUE_VALUES = ['yes', 'Yes', 'YES', 'true', 'True', 'TRUE', '1'] +_SUPPORTED_POLL_STRATEGIES = ['epoll1', 'poll'] + # This flag enables experimental support within gRPC Python for applications # that will fork() without exec(). When enabled, gRPC Python will attempt to # pause all of its internally created threads before the fork syscall proceeds. @@ -82,12 +84,14 @@ cdef void __postfork_child() nogil: def fork_handlers_and_grpc_init(): grpc_init() if _GRPC_ENABLE_FORK_SUPPORT: - # TODO(ericgribkoff) epoll1 is default for grpcio distribution. Decide whether to expose - # grpc_get_poll_strategy_name() from ev_posix.cc to get actual polling choice. - if _GRPC_POLL_STRATEGY is not None and _GRPC_POLL_STRATEGY != "epoll1": + # TODO(ericgribkoff) epoll1 is default for grpcio distribution (poll is + # default on mac). Decide whether to expose grpc_get_poll_strategy_name() + # from ev_posix.cc to get actual poller. + if (_GRPC_POLL_STRATEGY is not None and + _GRPC_POLL_STRATEGY not in _SUPPORTED_POLL_STRATEGIES): _LOGGER.error( 'gRPC Python fork support is only compatible with the epoll1 ' - 'polling engine') + 'and poll polling strategies') return with _fork_state.fork_handler_registered_lock: if not _fork_state.fork_handler_registered: |