pythonspyne

In Python got many issues with Spyne


Well, here's my Python code:

#!/usr/bin/env python
from spyne import Application, rpc, ServiceBase, Unicode
from lxml import etree
from spyne.protocol.soap import Soap11
from spyne.server.wsgi import WsgiApplication
# Wsgi это Web server Getewap Interface - стандар взаимодействия с питон программой и серверо где он работает

class Soap(ServiceBase):
    @rpc(Unicode, _return=Unicode)
    def Insoap(ctx, words):
        print("Connection detected: ", etree.tostring(ctx.in_document))
        ww = str(words).capitalize()
        return ww

app = Application([Soap], tns='Capitalize', in_protocol=Soap11(validator='lxml'), out_protocol=Soap11())
application = WsgiApplication(app) # Важна названия переменной, иначе сервер не поймет


if __name__ == '__main__':
    from wsgiref.simple_server import make_server
    server = make_server('localhost', 8002, application)
    server.serve_forever()

But get this error, what's the problem? What should I do for a solution? Please, get help me to solve this problem

Traceback (most recent call last):
  File "C:/Users/David374/PycharmProjects/untitled8/venv/test.py", line 3, in <module>
    from spyne import Application, rpc, ServiceBase, Iterable, UnsignedInteger, \
  File "C:\Users\David374\PycharmProjects\untitled8\venv\lib\site-packages\spyne\__init__.py", line 63, in <module>
    from spyne.server import ServerBase, NullServer
  File "C:\Users\David374\PycharmProjects\untitled8\venv\lib\site-packages\spyne\server\__init__.py", line 23, in <module>
    from spyne.server.null import NullServer
  File "C:\Users\David374\PycharmProjects\untitled8\venv\lib\site-packages\spyne\server\null.py", line 69
    self.service = _FunctionProxy(self, self.app, async=False)
                                                  ^
SyntaxError: invalid syntax

Solution

  • async is a reserved keyword in Python 3.7+, and you'll need to use the latest version of Spyne, which doesn't use that reserved keyword as a parameter in its functions, if you want to use it with Python 3.7+.

    Either update Spyne to spyne-2.13.2-alpha, or use Python 3.6 or lower.

    Sources: