# Can't get the single container example to work

**URL:** <https://discourse.nameko.io/t/cant-get-the-single-container-example-to-work/250>\
**Category:** googlegroup\
**Created:** [April 3, 2018, 6:02am UTC](https://discourse.nameko.io/t/cant-get-the-single-container-example-to-work/250 "2018-04-03T06:02:21Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kirkodouglasjr](https://avatars.discourse-cdn.com/v4/letter/k/65b543/32.png) [@Kirkodouglasjr](https://discourse.nameko.io/u/Kirkodouglasjr)\
**Post date:** [April 3, 2018, 6:02am UTC](https://discourse.nameko.io/t/cant-get-the-single-container-example-to-work/250/1 "2018-04-03T06:02:21Z")

</div>

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:guest@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:guest@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  
Broker: amqp://guest:guest@127.0.0.1:5672/

> > > 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.

---

<div class="post-metadata">

**Author:** ![mattbennett](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.nameko.io/mattbennett/32/13_2.png) [@mattbennett](https://discourse.nameko.io/u/mattbennett)\
**Post date:** [April 3, 2018, 8:01am UTC](https://discourse.nameko.io/t/cant-get-the-single-container-example-to-work/250/2 "2018-04-03T08:01:09Z")

</div>

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\](https://github.com/nameko/nameko/pull/531%5C).

> **···**
>
> On Tuesday, April 3, 2018 at 7:02:21 AM UTC+1, kirkodo...@gmail.com wrote:
> 
> > 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:guest@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:guest@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  
> > Broker: amqp://guest:guest@127.0.0.1:5672/  
> > \>\>\> 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.

---

<div class="post-metadata">

**Author:** ![Kirkodouglasjr](https://avatars.discourse-cdn.com/v4/letter/k/65b543/32.png) [@Kirkodouglasjr](https://discourse.nameko.io/u/Kirkodouglasjr)\
**Post date:** [April 3, 2018, 7:12pm UTC](https://discourse.nameko.io/t/cant-get-the-single-container-example-to-work/250/3 "2018-04-03T19:12:44Z")

</div>

Yes i realised after digging through more of the articles here. Thanks for  
adding that.

> **···**
>
> On Tuesday, April 3, 2018 at 3:01:09 AM UTC-5, Matt Yule-Bennett wrote:
> 
> > 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\](https://github.com/nameko/nameko/pull/531%5C).
> > 
> > On Tuesday, April 3, 2018 at 7:02:21 AM UTC+1, kirkodo...@gmail.com wrote:
> > 
> > > 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:guest@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:guest@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  
> > > Broker: amqp://guest:guest@127.0.0.1:5672/  
> > > \>\>\> 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.
