Streaming data with Pylons
Posted Sat, 09 Dec 2006
Pylons serves standard requests like a champ. However, I was finding it hard to convince controller methods to send data gradually in a stream. Some brief searching told me that Pylons 0.9.3 supported iterators for data. That is, you could have a controller yield data (using generators) and each yielded piece would be logically sent as it is generated.
However, I was never able to get it to work. I almost gave up when I did yet another search for answers. This search lead me to this thread which explains the solution. In the project config file (development.ini, or whatever), you need to disable debug mode before generators will work properly.
If debug mode is enabled, pylons will wait for data to finish sending (through generators or otherwise) before the data is actually given to the requesting client.