poll of filesystem

Belisko Marek marek.belisko at gmail.com
Sat Jul 2 05:40:46 EDT 2011


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



More information about the Python-list mailing list