Can't get the single container example to work

26 views
Skip to first unread message

kirkodo...@gmail.com

unread,
Apr 3, 2018, 2:02:21 AM4/3/18
to nameko-dev

I'm trying to make a script that will make a container and run a service for me using the code above. But when i connect to it using shell command hangs and doesn't get executed.

from nameko.containers import ServiceContainer
from nameko.rpc import rpc


class Service:
name = "servicee"

@rpc
def test(self):
return "hi"


# create a container
container = ServiceContainer(Service, config={"AMQP_URI": "amqp://guest:gu...@127.0.0.1:5672/"})

# ``container.extensions`` exposes all extensions used by the service
service_extensions = list(container.extensions)

# start service
container.start()

# stop service
container.stop()



Hanging in shell...

$ nameko shell --broker amqp://guest:gu...@127.0.0.1:5672/
Nameko Python 3.6.3 (default, Oct 10 2017, 16:21:48) 
[GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.42.1)] shell on darwin
>>> n.rpc.servicee
<nameko.rpc.ServiceProxy object at 0x10c7a2940>
>>> n.rpc.servicee.hi()


If i run the service directly running nameko run it works just fine. I'm making my own script because I want it to read from an .ini file instead of a yaml.

Message has been deleted

Matt Yule-Bennett

unread,
Apr 3, 2018, 4:01:09 AM4/3/18
to nameko-dev
You're missing the eventlet monkey patch. `nameko run` applies this for you; if you write your own runner you have to do it yourself.

You're not the first person to be confused by that page in the docs. I've added a sentence to clarify: https://github.com/nameko/nameko/pull/531.

kirkodo...@gmail.com

unread,
Apr 3, 2018, 3:12:44 PM4/3/18
to nameko-dev
Yes i realised after digging through more of the articles here. Thanks for adding that.
Reply all
Reply to author
Forward
0 new messages