##// END OF EJS Templates
util: add a simple poll utility...
Pierre-Yves David -
r25420:c2ec8189 default
parent child Browse files
Show More
@@ -8,6 +8,7 b''
8 from i18n import _
8 from i18n import _
9 import encoding
9 import encoding
10 import os, sys, errno, stat, getpass, pwd, grp, socket, tempfile, unicodedata
10 import os, sys, errno, stat, getpass, pwd, grp, socket, tempfile, unicodedata
11 import select
11 import fcntl, re
12 import fcntl, re
12
13
13 posixfile = open
14 posixfile = open
@@ -594,6 +595,19 b' def statisexec(st):'
594 '''check whether a stat result is an executable file'''
595 '''check whether a stat result is an executable file'''
595 return st and (st.st_mode & 0100 != 0)
596 return st and (st.st_mode & 0100 != 0)
596
597
598 def poll(fds):
599 """block until something happens on any file descriptor
600
601 This is a generic helper that will check for any activity
602 (read, write. exception) and return the list of touched files.
603
604 In unsupported cases, it will raise a NotImplementedError"""
605 try:
606 res = select.select(fds, fds, fds)
607 except ValueError: # out of range file descriptor
608 raise NotImplementedError()
609 return sorted(list(set(sum(res, []))))
610
597 def readpipe(pipe):
611 def readpipe(pipe):
598 """Read all available data from a pipe."""
612 """Read all available data from a pipe."""
599 # We can't fstat() a pipe because Linux will always report 0.
613 # We can't fstat() a pipe because Linux will always report 0.
@@ -54,6 +54,7 b' openhardlinks = platform.openhardlinks'
54 oslink = platform.oslink
54 oslink = platform.oslink
55 parsepatchoutput = platform.parsepatchoutput
55 parsepatchoutput = platform.parsepatchoutput
56 pconvert = platform.pconvert
56 pconvert = platform.pconvert
57 poll = platform.poll
57 popen = platform.popen
58 popen = platform.popen
58 posixfile = platform.posixfile
59 posixfile = platform.posixfile
59 quotecommand = platform.quotecommand
60 quotecommand = platform.quotecommand
@@ -371,6 +371,10 b' def statisexec(st):'
371 '''check whether a stat result is an executable file'''
371 '''check whether a stat result is an executable file'''
372 return False
372 return False
373
373
374 def poll(fds):
375 # see posix.py for description
376 raise NotImplementedError()
377
374 def readpipe(pipe):
378 def readpipe(pipe):
375 """Read all available data from a pipe."""
379 """Read all available data from a pipe."""
376 chunks = []
380 chunks = []
General Comments 0
You need to be logged in to leave comments. Login now