python - itertools aparent bug with pygraphviz and return chain to flask -
i finding possible bug chaining several methods in return statement in flask. wanted see if had suggestions on how around problem.
here code:
#!/usr/bin/env python import flask import time itertools import chain pygraphviz import agraph class testclass(object): def __init__(self): g = '' def worker(self): a='1234' b=a + '45\n' yield b time.sleep(3) yield def worker2(self): time.sleep(3) c = '\n9876' yield c def graph(self): g = agraph(overlap='false') tc = testclass() app = flask.flask(__name__) @app.route('/') def test_method_get_stuff(): return flask.render_template('index.html') @app.route('/', methods=['post']) def test_method_post_stuff(): def test_method_sub_function(): return chain(tc.worker(), tc.worker2(),tc.graph()) return flask.response(test_method_sub_function(),mimetype= 'text/plain') app.run(debug=true)
once post requested tc.worker()
, tc.worker2()
generators return correctly once tries perform tc.graph()
errors out below error.
* running on http://127.0.0.1:5000/ * restarting reloader 127.0.0.1 - - [17/aug/2014 18:23:17] "get / http/1.1" 200 - 127.0.0.1 - - [17/aug/2014 18:23:18] "post / http/1.1" 200 - debugging middleware caught exception in streamed response @ point response headers sent. traceback (most recent call last): file "/usr/lib/python2.7/site-packages/werkzeug/wsgi.py", line 691, in __next__ return self._next() file "/usr/lib/python2.7/site-packages/werkzeug/wrappers.py", line 81, in _iter_encoded item in iterable: typeerror: 'nonetype' object not iterable
Comments
Post a Comment