def upload(): check_login() form = UploadForm() if form.validate_on_submit(): content = parse_json(unicode(form.json.data.stream.getvalue(), encoding="utf-8")) jobs = [post(item) for item in content['items']] flash("All json objects posted", "success") return render_redirect(url_for('index')) return render_form(form=form, title='Upload Bulk wiktionary json file', submit=u'Login', cancel_url=url_for('index'), ajax=False)
def upload(): r = check_login() if r is not None: return r form = UploadForm() if form.validate_on_submit(): content = parse_json(unicode(form.json.data.stream.getvalue(), encoding="utf-8")) try: jobs = [(post(item), item) for item in content['items']] #jobs = [gevent.spawn(post, item) for item in content['items']] #gevent.joinall(jobs) #flash("All json objects posted - gevent", "success") except: flash("Something Wentwrong") return render_template('upload.html', jobs=jobs) return render_form(form=form, title='Upload Bulk wiktionary json file', submit=u'Upload', cancel_url=url_for('index'), ajax=False)