sanic-org/sanic

Error with Multiple workers on Windows

MangoTobi opened this issue · 5 comments

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 on Windows? We tried it on Mac where it works.

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)

Environment
windows 10
python 3.6.6
Vue: 3.5.0

Windows support is "experimental" and on a best-effort basis; I'm going to leave this open for now but it may ultimately get closed as windows isn't a primary testing target for us, so we can't guarantee everything works.

FYI an alternative for windows is testing within the Windows Subsystem for Linux (WSL), this environment works very well for me when i need to use Windows in my work.

I encountered the same error on Windows 10. Cant use more than one worker. I get the same error but on all routes, not just static ones.

stale commented

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If this is incorrect, please respond with an update. Thank you for your contributions.

I don't see the point of having stale bot just auto close issues. A dupe of this issue was already closed in favor of this one and this finally just got auto closed. Are people supposed to continuously open new issues for the same thing that gets auto-closed? It would at the very least be nice to have a "wont-fix" label or some acknowledgement before letting issues be auto-closed so users can move on if this doesn't suit their needs.