Comet support

16 views
Skip to first unread message

azer

unread,
Apr 10, 2008, 1:44:47 PM4/10/08
to Google App Engine
Hi,

I'm trying to use time.sleep and stdout.flush commands but it doesn't
work.Here is the code:

self.response.out.write('Hello')
sys.stdout.flush()
time.sleep(3)
self.response.out.write(' world!')

When I run this code appengine waits 3 seconds and prints "hello
world!" but it should print "hello" before waiting.How can i solve
this problem?

Thanks,
Azer Koçulu
http://azer.kodfabrik.com

Dan Sanderson

unread,
Apr 10, 2008, 5:53:29 PM4/10/08
to Google App Engine
On Apr 10, 10:44 am, azer <a...@kodfabrik.com> wrote:
> Hi,
>
> I'm trying to use time.sleep and stdout.flush commands but it doesn't
> work.Here is the code:
>
> self.response.out.write('Hello')
> sys.stdout.flush()
> time.sleep(3)
> self.response.out.write(' world!')
>
> When I run this code appengine waits 3 seconds and prints "hello
> world!" but it should print "hello" before waiting.How can i solve
> this problem?

App Engine does not support streaming responses, so you won't be able
to do this. Everything printed to stdout is buffered, then sent when
the handler returns. (This is true for App Engine in general, not
just webapp.)

-- Dan

Rapheal Kaplan

unread,
Apr 10, 2008, 6:07:52 PM4/10/08
to google-a...@googlegroups.com
  All of the output is buffered and sent at the end of the request.  It is not possible to have part of your text appear first and the rest later the way you are attempting.  If you need to have a dynamic page that updates over time, you might want to use simple Ajax.
--

- 'Chops

azer

unread,
Apr 11, 2008, 3:29:08 AM4/11/08
to Google App Engine
Adding streaming support to AppEngine would be great.I think that it's
too important to web based applications.

thanks,
azer
Reply all
Reply to author
Forward
0 new messages