how to make a periodic post after X seconds

406 views
Skip to first unread message

aliane abdelouahab

unread,
Sep 27, 2012, 6:43:38 AM9/27/12
to Tornado Web Server
hi
i discovered Facebook API, and sadly, i dont allow users to send
status updates instantly, so to hack this, i imaginated to store the
notification (when someone do something, it will be posted to
facebook) in the database, and then, retrieved those information to
post them after each 5 minutes for example, but i think this will
block, and in tornado, i heared that i exists a way to do it without
blocking, is it possible.
can you please provide me a simple:

for i in "hello":
print i
since this program will show h, e, l, l, o
so i want to know how to delay them: "h" then after one minute "e" ...

Lorenzo Bolla

unread,
Sep 27, 2012, 8:04:33 AM9/27/12
to python-...@googlegroups.com
import time
import tornado.ioloop


def delayed_print(s):
if len(s) == 0:
ioloop.stop()
else:
print s[0]
ioloop.add_timeout(time.time() + 1, lambda:
delayed_print(s[1:]))


ioloop = tornado.ioloop.IOLoop()
delayed_print('hello world')
ioloop.start()


L.

aliane abdelouahab

unread,
Sep 27, 2012, 8:11:21 AM9/27/12
to Tornado Web Server
this will not block the server untill all the word finish?

aliane abdelouahab

unread,
Sep 27, 2012, 8:12:41 AM9/27/12
to Tornado Web Server
oups, sorry, just read the doc :p
thank you and sorry again :)
Reply all
Reply to author
Forward
0 new messages