summaryrefslogtreecommitdiff
path: root/examples/hello_callback.py
blob: f192c8dc75568f43773d34ecb31826cc23cb8207 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
"""Print 'Hello World' every two seconds, using a callback."""

import trollius


def print_and_repeat(loop):
    print('Hello World')
    loop.call_later(2, print_and_repeat, loop)


if __name__ == '__main__':
    loop = trollius.get_event_loop()
    print_and_repeat(loop)
    try:
        loop.run_forever()
    finally:
        loop.close()