Nameko

raw JSON →
2.14.1 verified Mon Apr 27 auth: no python

A microservices framework for Python that lets service developers concentrate on application logic and encourages testability. Current stable release is 2.14.1, with a release candidate for 3.0.0 available. Release cadence is irregular, with major updates every few years.

pip install nameko
error ModuleNotFoundError: No module named 'nameko'
cause Nameko not installed or running in wrong environment.
fix
pip install nameko
error pika.exceptions.AMQPConnectionError: Connection closed by remote server
cause RabbitMQ not running or unreachable.
fix
Ensure RabbitMQ is running and accessible. Check AMQP_URI config.
error AttributeError: module 'nameko' has no attribute 'rpc'
cause Incorrect import path. Use 'from nameko.rpc import rpc'.
fix
Correct import: from nameko.rpc import rpc
breaking In v2.x, nameko automatically patches eventlet. In v3.x, this is removed and must be done manually.
fix If upgrading to v3.x, ensure your code does not rely on automatic monkey-patching. Import eventlet and call eventlet.monkey_patch() if needed.
gotcha Async RPC calls: using ServiceRpcProxy in an async context can cause deadlocks if not handled correctly.
fix Use ServiceRpcProxy in synchronous code only, or use nameko's async extensions if available.
deprecated nameko backdoor command was removed in v3.0.0-rc7.
fix Use alternative debugging methods such as pdb or remote debugging.

Define a simple RPC service and run it using the nameko CLI.

from nameko.rpc import rpc
from nameko.standalone.rpc import ServiceRpcProxy

class GreetingService:
    name = 'greeting_service'

    @rpc
    def hello(self, name):
        return f'Hello, {name}!'

if __name__ == '__main__':
    from nameko.runners import ServiceRunner
    from nameko.containers import ServiceContainer
    from nameko.cli.main import run
    # Run with: nameko run service:GreetingService
    print('Run with: nameko run <module>:GreetingService')