so normally if i run a python scriptthese script with this code:
x=5
exec("x+=1")
output=str(x)
atIf I execute the end of thisabove in a python console, output has a value of "6" as expected
but But if it's run inside a wsgi app:
x=5
exec("x+=1")
output=str(x)
now output = "5"function, the exec doesn't change the value of x.
Why does this happen, and how cancould I get the exec to behave like normal python (3).
Please don't let this thread turn into a debate about using exec. I want to use exec, is it possible inside wsgi?
BTW: eval() seems to works normally inside wsgi. Also: I see this running mod_wsgisame behavior in daemon and embedded mode, I also see it without mod_wsgi using python wsgiref.simple_server.
here is the full code of a little wsgi app wherefunction as i do in the exec command doesnt seem to have an effect:console?
from wsgiref.simple_server import make_server
def app(environ, start_response):
status = '200 OK'
response_headers = [('content-type', 'text/html')]
start_response(status,response_headers)
x=5
exec("x+=1")
ret = str(x)
return [bytes(ret.encode('UTF-8'))]
application = app
httpd = make_server('', 88, app)
print("Serving on port 88...")
httpd.serve_forever()