#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2004
    Posts
    1
    Rep Power
    0

    Exclamation Python app Segfaults


    The following methods:
    Code:
    def __getDirContent( self, directory, count ):
    		name = directory
    		contents = []
    		length = 1
    		for object in os.listdir( directory ):
    			if os.path.isdir( os.path.join( directory, object ) ):
    				contents.extend( self.__getDirContent( os.path.join( directory, object ), count + len( contents ) ) )
    			elif self.formatClasses.has_key( object[-3:] ):
    				self.files.append( self.formatClasses[object[-3:]]( os.path.join( directory, object ) ) )
    				#contents.append( os.path.join( directory, object ) 
    				self.counter += 1
    			if self.config["VERBOSE"]:
    				self.__updateCounter( "\tFound", "files to process" )
    		return contents
    
    def getFiles( self ):	
    		dirs = [ re.sub( r"(^ | $)", "", target ) for target in self.config["READFROM"].split( ";" ) ]
    		for target in dirs:
    			if os.path.isdir( target ):
    				self.files.extend( self.__getDirContent( target, len( self.files ) ) )
    			else:
    				print "Warning: `" + target + "' is not a directory, omitting"
    		
    		if self.config["VERBOSE"]:
    			sys.stdout.write( "\n" )
    Produces this output when run on a directory with > 100 files:
    Code:
    Retrieving files
            Found 16 files to processzsh: segmentation fault  python mlm.py
    What can be causing this?

    If I run it on a directory that doesn't contain that many files, it works well.
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Feb 2004
    Location
    London, England
    Posts
    1,585
    Rep Power
    1373
    there doesn't seem to be anything in the code you have posted that would cause a segfault - these usually come from third party C/C++ extensions.

    You only posted part of the code - where is the code for __updateCounter?

    Dave - The Developers' Coach

IMN logo majestic logo spyfu logo threadwatch logo seochat tools logo