Added basic worker thread back in, and TODO comments for multi-threading this new script.
This commit is contained in:
		
							parent
							
								
									59e010d682
								
							
						
					
					
						commit
						3ffdd76147
					
				
					 1 changed files with 38 additions and 0 deletions
				
			
		|  | @ -212,6 +212,34 @@ class Console( threading.Thread ): | |||
| 
 | ||||
|             self.queue.task_done( ) | ||||
| 
 | ||||
| class Worker( threading.Thread ): | ||||
|     def __init__( self, console, queue, files_to_ignore ): | ||||
|         threading.Thread.__init__( self ) | ||||
| 
 | ||||
|         self.console = console | ||||
|         self.queue = queue | ||||
|         self.files_to_ignore = files_to_ignore | ||||
| 
 | ||||
|     def run( self ): | ||||
|         while True: | ||||
|             ( cmd, data ) = self.queue.get( ) | ||||
| 
 | ||||
|             if cmd == MSG.SHUTDOWN: | ||||
|                 self.queue.task_done( ) | ||||
|                 self.console.flush( ) | ||||
|                 break | ||||
| 
 | ||||
|             if cmd != MSG.PARSE_DIRECTORY or data is None: | ||||
|                 self.console.flush( ) | ||||
|                 self.queue.task_done( ) | ||||
|                 continue | ||||
| 
 | ||||
|             directory = data | ||||
| 
 | ||||
|             # add threading stuffs | ||||
| 
 | ||||
|             self.queue.task_done( ) | ||||
| 
 | ||||
| def main( args ): | ||||
|     # check requirements | ||||
|     if call_process( 'p4 -V' ) != 0: | ||||
|  | @ -242,8 +270,18 @@ def main( args ): | |||
|     with Console( auto_flush_num=20, auto_flush_time=1000 ) as c: | ||||
|         if not options.quiet: | ||||
|             c.writeflush( "Caching files in depot, this may take a little while..." ) | ||||
| 
 | ||||
|         # TODO: push this off to a thread and walk the directory so we get a headstart. | ||||
|         files_in_depot = get_client_set( directory ) | ||||
| 
 | ||||
|         # TODO: push a os.walk request off to a thread to build a list of files in the directory; create batch based on directory? | ||||
| 
 | ||||
|         # TODO: at this point join on both tasks to wait until they're done | ||||
| 
 | ||||
|         # TODO: kick off file removal, make batches from the files for threads to work on since testing has to be done for each. | ||||
|         #       need to figure out the best way to do this since the ignore list needs to be properly built for each directory; | ||||
|         #       will at least need to redo how the ignore lists are handled for efficiencies sake. | ||||
| 
 | ||||
|         if not options.quiet: | ||||
|             c.writeflush( "Checking " + directory) | ||||
|         for root, dirs, files in os.walk( directory ): | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue