Launching a jar + gevent + requests that do not serve "simultaneously"

I run my jar application as follows:

#!flask/bin/python from app import app_instance from gevent.pywsgi import WSGIServer #returns and instance of the application - using function to wrap configuration app = app_instance() http_server = WSGIServer(('',5000), app) http_server.serve_forever() 

And then when I try to execute this code, the requests call the blocks until the initial request has expired. I mainly refer to the web service in the same flash application. What i don't understand about gevent? Will the stream be issued when an I / O event occurs?

 @webapp.route("/register", methods=['GET', 'POST']) def register(): form = RegistrationForm(request.form, csrf_enabled=False) data = None if request.method == 'POST' and form.validate(): data= {'email': form.email, 'auth_token': form.password, 'name' : form.name, 'auth_provider' : 'APP'} r = requests.post('http://localhost:5000', params=data) print('status' + str(r.status_code)) print(r.json()) return render_template('register.html', form=form) 
+6
source share
1 answer

I believe the problem is that you forgot the monkey patch. This makes all normally blocking calls become non-blocking calls that use green. To do this, just put this code before you call anything else.

 from gevent import monkey; monkey.patch_all() 

Go to http://www.gevent.org/intro.html#monkey-patching for more information about this.

+16
source

All Articles