Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #8660
| Date | 2011-07-02 11:40 +0200 |
|---|---|
| Subject | poll of filesystem |
| From | Belisko Marek <marek.belisko@gmail.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.557.1309599650.1164.python-list@python.org> (permalink) |
Hi,
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?
Code:
#!/usr/bin/python
import select
from select import POLLIN, POLLERR
p = select.poll()
fd = open("/proc/loadavg", "r")
p.register(fd.fileno(), POLLIN)
while True:
events = p.poll(1000)
if (events == -1):
print "timeout"
fd0, event = events[0]
if (event == POLLIN):
print fd.read()
Thanks,
marek
--
as simple and primitive as possible
-------------------------------------------------
Marek Belisko - OPEN-NANDRA
Freelance Developer
Ruska Nova Ves 219 | Presov, 08005 Slovak Republic
Tel: +421 915 052 184
skype: marekwhite
icq: 290551086
web: http://open-nandra.com
Back to comp.lang.python | Previous | Next — Next in thread | Find similar | Unroll 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