Просмотр исходного кода

Add 'worker_rpc_timeout' config option.

Nashwan Azhari 8 лет назад
Родитель
Сommit
dc480f576d
1 измененных файлов с 14 добавлено и 2 удалено
  1. 14 2
      coriolis/worker/rpc/client.py

+ 14 - 2
coriolis/worker/rpc/client.py

@@ -1,6 +1,7 @@
 # Copyright 2016 Cloudbase Solutions Srl
 # All Rights Reserved.
 
+from oslo_config import cfg
 import oslo_messaging as messaging
 
 from coriolis import rpc
@@ -8,10 +9,21 @@ from coriolis import rpc
 VERSION = "1.0"
 
 
+worker_opts = [
+    cfg.IntOpt("worker_rpc_timeout",
+               help="Number of seconds until RPC calls to the worker timeout.")
+]
+
+CONF = cfg.CONF
+CONF.register_opts(worker_opts, 'worker')
+
+
 class WorkerClient(object):
-    def __init__(self):
+    def __init__(self, timeout=None):
         target = messaging.Target(topic='coriolis_worker', version=VERSION)
-        self._client = rpc.get_client(target)
+        if timeout is None:
+            timeout = CONF.worker.worker_rpc_timeout
+        self._client = rpc.get_client(target, timeout=timeout)
 
     def begin_task(self, ctxt, server, task_id, task_type, origin, destination,
                    instance, task_info):