Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #8673

Re: poll of filesystem

From Nobody <nobody@nowhere.com>
Subject Re: poll of filesystem
Date 2011-07-02 18:49 +0100
Message-Id <pan.2011.07.02.17.49.17.495000@nowhere.com>
Newsgroups comp.lang.python
References <mailman.557.1309599650.1164.python-list@python.org>
Organization Zen Internet

Show all headers | View raw


On Sat, 02 Jul 2011 11:40:46 +0200, Belisko Marek wrote:

> just want to use poll method to get data from /proc file system. Use
> simple code for it. Problem is it seems poll return POLLIN flag but
> when I try to read data it's always empty. Could be a problem changes
> are so fast that print can't print it?

poll() doesn't work for files; they are always readable. It's meant for
pipes, sockets and character devices (ttys, etc). If you're looking for a
way to find out when a file has changed, there isn't one (Linux has
inotify, but that isn't portable and it doesn't work with /proc).

The reason why fd.read() doesn't return any data after the first call is
that you're already at EOF; you need to reset the file position with
fd.seek(0) to read more data (however: for /proc, I would recommend
closing the file and reopening it).

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

poll of filesystem Belisko Marek <marek.belisko@gmail.com> - 2011-07-02 11:40 +0200
  Re: poll of filesystem Nobody <nobody@nowhere.com> - 2011-07-02 18:49 +0100
  Re: poll of filesystem Tim Roberts <timr@probo.com> - 2011-07-02 15:37 -0700

csiph-web