problem running spyne with uwsgi , unable to find "application" callable

176 Views Asked by At

Good morning everyone, I have problems with soap/spyne with uwsgi server

This is a semplification of my code :

server.py

soap_namespace = 'somenamespace'

class XmlReturn(ComplexModel):
    status = Boolean
    message = String
    exception = String

class Xml(ServiceBase):
    ##
    @srpc(AnyXml, _returns=XmlReturn)
    def SendData(p):   
        r = XmlReturn()
        print("Received: %s", etree.tostring(p, pretty_print=True))
 
        smsg = save_file(p)
        r.status = smsg["status"]
        r.message = smsg["message"]
        r.exception = smsg["exception"]
        return r

if __name__ == '__main__':

    from wsgiref.simple_server import make_server

    application = Application(
        services=[Xml],
        tns=soap_namespace,
        in_protocol=Soap11(validator='lxml'),
        out_protocol=Soap11())

    application = WsgiApplication(application)


    server = make_server('0.0.0.0', 8000, application)
    server.serve_forever()

this is a config file :

server.ini

[uwsgi]
http = :8000
chdir = /home/to/server/
wsgi-file = server.py

master = true
processes = 2

thunder-lock = true
#buffer-size = 65535

enable-threads = true
threads = 2

when i run the server with

uwsgi --ini server.ini

I get : "Unable to find "application" callable in file server.py" "unable to load app o (mountpoint '')"

I know how to setup and connect app/application running with uwsgi in flask, but with spyne I have no idea how to fix this problem, can someone help me please ?

Thanks for help

1

There are 1 best solutions below

0
On

You need application to be unconditionally instantiated.

Here's the corrected part of your code:

application = Application(
        services=[Xml],
        tns=soap_namespace,
        in_protocol=Soap11(validator='lxml'),
        out_protocol=Soap11())

application = WsgiApplication(application)


if __name__ == '__main__':
    from wsgiref.simple_server import make_server

    server = make_server('0.0.0.0', 8000, application)
    server.serve_forever()