Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b50e1de

Browse files
committed
Note lack of speedup. Remove Irix reference. Remove silly extra
'/tmp' arg. Change predicate to look for world-writable non-symlink files.
1 parent 5e31c3f commit b50e1de

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

Demo/threads/find.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,16 @@
33
# This demonstrates the use of a work queue and worker threads.
44
# It really does do more stats/sec when using multiple threads,
55
# although the improvement is only about 20-30 percent.
6+
# (That was 8 years ago. In 2002, on Linux, I can't measure
7+
# a speedup. :-( )
68

79
# I'm too lazy to write a command line parser for the full find(1)
810
# command line syntax, so the predicate it searches for is wired-in,
911
# see function selector() below. (It currently searches for files with
10-
# group or world write permission.)
12+
# world write permission.)
1113

1214
# Usage: parfind.py [-w nworkers] [directory] ...
13-
# Default nworkers is 4, maximum appears to be 8 (on Irix 4.0.2)
15+
# Default nworkers is 4
1416

1517

1618
import sys
@@ -98,7 +100,6 @@ def run(self, nworkers):
98100
# Main program
99101

100102
def main():
101-
sys.argv.append("/tmp")
102103
nworkers = 4
103104
opts, args = getopt.getopt(sys.argv[1:], '-w:')
104105
for opt, arg in opts:
@@ -122,8 +123,8 @@ def main():
122123
# Feel free to change this to suit your purpose
123124

124125
def selector(dir, name, fullname, stat):
125-
# Look for group or world writable files
126-
return (stat[ST_MODE] & 0022) != 0
126+
# Look for world writable files that are not symlinks
127+
return (stat[ST_MODE] & 0002) != 0 and not S_ISLNK(stat[ST_MODE])
127128

128129

129130
# The find procedure -- calls wq.addwork() for subdirectories

0 commit comments

Comments
 (0)