How can I tail a log file in Python?

前端 未结 12 2206
故里飘歌
故里飘歌 2020-11-22 10:50

I\'d like to make the output of tail -F or something similar available to me in Python without blocking or locking. I\'ve found some really old code to do that here, but I\'

12条回答
  •  孤街浪徒
    2020-11-22 11:00

    Another option is the tailhead library that provides both Python versions of of tail and head utilities and API that can be used in your own module.

    Originally based on the tailer module, its main advantage is the ability to follow files by path i.e. it can handle situation when file is recreated. Besides, it has some bug fixes for various edge cases.

提交回复
热议问题