Giter Club home page Giter Club logo

Comments (3)

mattbennett avatar mattbennett commented on July 23, 2024

Your server script starts and then immediately stops the service https://github.com/jiamo/nameko_research/blob/master/test_service_server.py#L32

You don't need to create a ServiceRunner yourself. You can use the nameko command line to run your service:

$ nameko run test_service_server --config nameko_server.conf
('config is ', {'AMQP_URI_CONFIG_KEY': 'amqp://guest:guest@localhost', 'max_workers': 10, 'AMQP_URI': 'amqp://guest:guest@localhost', 'parent_calls_tracked': 10, 'rpc_exchange': 'nameko-rpc'})
starting services: helloworld
Connected to amqp://guest:**@127.0.0.1:5672//

Also there is no need to implement the service client as you have. Just use the nameko command line:

nameko shell --config nameko_server.conf
>>> n.rpc.helloworld.hello(name='John')
u'Hello, John!'

from nameko.

jiamo avatar jiamo commented on July 23, 2024

Thanks. Some times we need run without nameko command.
After using nameko run test_service_server --config nameko_server.conf
my client py can work now.
But after comment the runner.stop(), python test_service_server.py still can' t work.

from nameko.

mattbennett avatar mattbennett commented on July 23, 2024

You need to both apply the eventlet monkey patch and call wait() on the runner to block until it exits.

index e764db8..8597563 100644
--- a/test_service_server.py
+++ b/test_service_server.py
@@ -1,3 +1,6 @@
+import eventlet
+eventlet.monkey_patch()
+
 from nameko.rpc import rpc
 from nameko.runners import ServiceRunner
 from nameko.testing.utils import get_container
@@ -29,7 +32,7 @@ def main():
     # start both services
     runner.start()

-    runner.stop()
+    runner.wait()
     # container = ServiceContainer(HelloWorldService, config=config)
     # service_extensions = list(container.extensions)
     # print ("service_extensions is ", service_extensions)

You should really consider using the code from nameko.cli.run even if you don't use the command line script, because the signal handing is non-trivial. For example, see https://github.com/onefinestay/nameko/blob/master/nameko/cli/run.py#L134

I'm going to close this issue now. If you have more questions about how to use nameko please post them to the (new!) google group.

from nameko.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.