How can i combine flask and nameko?

Contributor to nameko here. I agree with nathancahill that celery is a good choice for this.

You absolutely can use nameko and Flask together. There’s a short example in a gist here: https://gist.github.com/mattbennett/4250ce5d56b36a99bc39

In that configuration though, you're covering the same ground that Celery was built for -- namely handling long-running tasks outside the request-response cycle. Frankly the example in the gist would be much better implemented exclusively as a nameko app (using the built-in http entrypoint), because it’s not using any of the more advanced web framework-like features that Flask gives you.

If you want to write microservices, even ones that are predominantly HTTP based, nameko provides some nice tooling for doing so. If you just want to add async processing to an existing webapp, celery would be the standard choice.


In gateway import flask

from flask import Flask
app = Flask(__name__)

Example:

import json
from nameko.rpc import RpcProxy
from nameko.web.handlers import http
from flask import Flask, render_template, request, redirect, url_for

app = Flask(__name__)