tail -f in python with no time.sleep

后端 未结 10 1835
耶瑟儿~
耶瑟儿~ 2020-11-30 02:45

I need to emulate \"tail -f\" in python, but I don\'t want to use time.sleep in the reading loop. I want something more elegant like some kind of blocking read, or select.se

10条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-11-30 03:09

    If you can use GLib on all platforms, you should use glib.io_add_watch; then you can use a normal GLib mainloop and process events as they happen, without any polling behavior.

    http://library.gnome.org/devel/pygobject/stable/glib-functions.html#function-glib--io-add-watch

提交回复
热议问题