I want to call several rpc entrypoints when my service is started. My solution is below. But it has fault.
def main():
runner = create_service_runner(cfg['nameko'])
runner.start()
if not on_service_start(cfg['nameko']):
raise RuntimeError('Failed to setup service.')
runner.wait()
def on_service_start(cfg) -> bool:
with ServiceRpcProxy('my_service', cfg['nameko'], timeout=5 * 60) as rpc:
return rpc.init1() and rpc.init2()
eventlet blames below. Furthermore, if my_service is deployed in a cluster, it cannot guarantee all nodes get correct amount of rpc requests.
nameko.exceptions.RemoteError: RuntimeError Second simultaneous read on fileno 6 detected. Unless you really know what you’re doing, make sure that only one greenthread can read any particular socket. Consider using a pools.Pool. If you do know what you’re doing and want to disable this error, call eventlet.debug.hub_prevent_multiple_readers(False) - MY THREAD=<built-in method switch of GreenThread object at 0x7f477efa8c00>; THAT THREAD=FdListener(‘read’, 6, <built-in method switch of GreenThread object at 0x7f478016e470>, <built-in method throw of GreenThread object at 0x7f478016e470>)
Is there a better way to call ‘my_service’ entrypoint in ‘my_service’ project itself?