unbit / uwsgi

uWSGI application server container
http://projects.unbit.it/uwsgi
Other
3.43k stars 678 forks source link

Python 3, multiapp mode, application dictionary not mounting applications #1301

Open sloat opened 8 years ago

sloat commented 8 years ago

Tested on OSX 10.10, Python 3.5.1

import uwsgi

import front
import api

uwsgi.applications = {
    '': front.app,
    '/api': api.app,
    }

Results in:

found a multiapp module...
the app mountpoint must be a string
*** no app loaded. going in full dynamic mode ***

Solution: Use bytes for the dictionary keys.

uwsgi.applications = {
    b'': front.app,
    b'/api': api.app,
    }

Result:

found a multiapp module...
WSGI app 0 (mountpoint='') ready in 0 seconds on interpreter 0x7f89ba6007d0 pid: 42839 (default app)
WSGI app 1 (mountpoint='/api') ready in 0 seconds on interpreter 0x7f89ba6007d0 pid: 42839
xrmx commented 8 years ago

Could you point out what's the issue you are reporting please?

sloat commented 8 years ago

Python 3 WSGI applications aren't mounted with the uwsgi.applications dictionary unless the dict keys are bytes. I wasn't sure if I should post it to uwsgi-docs or here, since googling led me to the source repo, but it's not a major issue or anything.

Mostly I just wanted to post in case someone else was having the same problem.

xrmx commented 8 years ago

@sloat I think you overlooked the app mountpoint must be a string warning. Feel free to open a pull request improving the message.

juansaavedrauy commented 4 years ago

Can confirm it actually picks up the applications, but it doesn't work as expected as far as I can tell. Maybe the bytes representation is cause for #1163?

Chris2048 commented 3 years ago

@xrmx In the first example the mount-points are dict keys, aren't they? If so those are strings.