Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

serve.py waits for all results #8

Open
fginter opened this issue Mar 13, 2015 · 1 comment
Open

serve.py waits for all results #8

fginter opened this issue Mar 13, 2015 · 1 comment

Comments

@fginter
Copy link
Owner

fginter commented Mar 13, 2015

the communicate() function which is used to run query.py has the problem that it waits for all results to be finished before returning. A query for something rare then becomes slow, even though first results may be available within seconds. It is a simple thing to use pipes and get the output as query.py produces it (we just need to add flush() calls into query). But will the browser show the results as they keep coming? I.e. is the browser rendering the page while it is receiving it, or does it wait for the load to finish before it starts doing something?

@spyysalo
Copy link
Collaborator

In general, modern browsers will start rendering incomplete pages after a bit of delay. There's something of a black art of making pages work well with this feature, but it should not be impossible to take advantage of it.

At the moment, the function query_and_fill_template() waits for all results and then formats them for return, so chaging the communicate() bit wouldn't help. What needs to be done is to rewrite the whole query response bit to yield the start of the document immediately (the framework will send over anything that rendering functions yield to it), and then yield the results as they come in over the pipe.

This will require giving up the current template approach and instead split the HTML into pieces that can be sent over independently (mainly head, tail, and anything that wraps individual results).

I should be able to look into this next week, ping me if you don't hear back.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants