You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am using the following config in my deployed environments - Rails.application.configure do config.cache_classes = true config.eager_load = true end
If I call Temporal.start_worflow with above configuration, I get - RuntimeError: grpc cannot be used before and after forking from /bundle/ruby/2.6.0/gems/grpc-1.50.0-x86_64-linux/src/ruby/lib/grpc/generic/client_stub.rb:493:in create_call'`
However if both cache_classes and eager_load is set to false, it works.
Any suggestions on how I can resolve this?
The text was updated successfully, but these errors were encountered:
RuntimeError: grpc cannot be used before and after forking
Description:
When using the Puma server with multiple workers, I encountered the grpc that cannot be used before and after forking error. This issue occurs when there is more than one worker in Puma. The error arises because the grpc library is not designed to be safely used before and after the forking process, which happens in a multi-process environment.
Cause:
Puma uses the fork mechanism to create multiple worker processes for handling concurrent requests. However, the grpc library may encounter conflicts if it is initialized before and after forking, leading to the mentioned error.
Solution:
To address this issue, move the initialization of grpc inside the on_worker_boot block in the Puma configuration (config/puma.rb). The on_worker_boot block ensures that the grpc library is initialized in each worker process separately, avoiding conflicts and enabling smooth functioning in a multi-worker environment.
# config/puma.rbon_worker_bootdoTemporal.configuredo |config|
config.host='localhost'config.port=7233config.namespace='ruby-samples'config.task_queue='hello-world'config.credentials=GRPC::Core::ChannelCredentials.new# :this_channel_is_insecure does not work for meendend
By moving the grpc initialization inside on_worker_boot, each worker process will have its own isolated instance of grpc, resolving the grpc cannot be used before and after forking error and ensuring proper functioning in a multi-worker environment.
I am using the following config in my deployed environments -
Rails.application.configure do config.cache_classes = true config.eager_load = true end
If I call Temporal.start_worflow with above configuration, I get -
RuntimeError: grpc cannot be used before and after forking from /bundle/ruby/2.6.0/gems/grpc-1.50.0-x86_64-linux/src/ruby/lib/grpc/generic/client_stub.rb:493:in
create_call'`However if both cache_classes and eager_load is set to false, it works.
Any suggestions on how I can resolve this?
The text was updated successfully, but these errors were encountered: