Fixing the server example code
Added server.stop() before server.wait() Change-Id: I9764c77e0aa076b6a7b9bb9715e2ead89b12126f
This commit is contained in:
parent
d3bb45fe34
commit
33243c26ac
@ -229,7 +229,7 @@ class RPCClient(object):
|
||||
class TestClient(object):
|
||||
|
||||
def __init__(self, transport):
|
||||
target = messaging.Target(topic='testtopic', version='2.0')
|
||||
target = messaging.Target(topic='test', version='2.0')
|
||||
self._client = messaging.RPCClient(transport, target)
|
||||
|
||||
def test(self, ctxt, arg):
|
||||
@ -254,7 +254,7 @@ class RPCClient(object):
|
||||
For example::
|
||||
|
||||
transport = messaging.get_transport(cfg.CONF)
|
||||
target = messaging.Target(topic='testtopic', version='2.0')
|
||||
target = messaging.Target(topic='test', version='2.0')
|
||||
client = messaging.RPCClient(transport, target)
|
||||
client.call(ctxt, 'test', arg=arg)
|
||||
|
||||
|
@ -44,6 +44,7 @@ A simple example of an RPC server with multiple endpoints might be::
|
||||
|
||||
from oslo_config import cfg
|
||||
import oslo_messaging
|
||||
import time
|
||||
|
||||
class ServerControlEndpoint(object):
|
||||
|
||||
@ -54,7 +55,7 @@ A simple example of an RPC server with multiple endpoints might be::
|
||||
self.server = server
|
||||
|
||||
def stop(self, ctx):
|
||||
if server:
|
||||
if self.server:
|
||||
self.server.stop()
|
||||
|
||||
class TestEndpoint(object):
|
||||
@ -70,7 +71,14 @@ A simple example of an RPC server with multiple endpoints might be::
|
||||
]
|
||||
server = oslo_messaging.get_rpc_server(transport, target, endpoints,
|
||||
executor='blocking')
|
||||
server.start()
|
||||
try:
|
||||
server.start()
|
||||
while True:
|
||||
time.sleep(1)
|
||||
except KeyboardInterrupt:
|
||||
print("Stopping server")
|
||||
|
||||
server.stop()
|
||||
server.wait()
|
||||
|
||||
Clients can invoke methods on the server by sending the request to a topic and
|
||||
|
Loading…
x
Reference in New Issue
Block a user