We build a project with Sanic and vue.js on Windows. When we try to run the app with more than 1 worker we have the following error:
AttributeError: Can’t pickle local object ‘register.._handler’
However, when we comment the following line out, sanic starts with multiple workers but of course doesn’t serve the static files:
app.static(‘static’, ‘…/…/dist/static’)
Isn’t sanic able to run with multiple workers and serve static files at all?
main.py:
app = Sanic()
app.static('/static', './dist/static')
@app.route('/')
async def index(request):
template = open(os.getcwd() + '/dist/index.html')
return html(template.read())
run.py
if __name__ == "__main__":
app.run(host='0.0.0.0', port=5000, workers=2)