docs/core/examples/filewatch.py
raw| 1 | # Copyright (c) Twisted Matrix Laboratories. |
| 2 | # See LICENSE for details. |
| 3 | |
| 4 | # |
| 5 | from twisted.application import internet |
| 6 | |
| 7 | |
| 8 | def watch(fp): |
| 9 | fp.seek(fp.tell()) |
| 10 | for line in fp.readlines(): |
| 11 | sys.stdout.write(line) |
| 12 | |
| 13 | |
| 14 | import sys |
| 15 | |
| 16 | from twisted.internet import reactor |
| 17 | |
| 18 | s = internet.TimerService(0.1, watch, open(sys.argv[1])) |
| 19 | s.startService() |
| 20 | reactor.run() |
| 21 | s.stopService() |