Adding new worker run type

This commit is contained in:
Brian 2014-05-14 19:09:46 -06:00
parent 3ffdd76147
commit 6236ead338
1 changed files with 18 additions and 2 deletions

View File

@ -29,7 +29,7 @@ def enum(*sequential, **named):
enums = dict(zip(sequential, range(len(sequential))), **named)
return type('Enum', (), enums)
MSG = enum('SHUTDOWN', 'PARSE_DIRECTORY')
MSG = enum('SHUTDOWN', 'PARSE_DIRECTORY', 'RUN_FUNCTION')
p4_ignore = ".p4ignore"
@ -212,6 +212,19 @@ class Console( threading.Thread ):
self.queue.task_done( )
class Task( threading.Event ):
def __init__( data, cmd = None ):
threading.Event.__init__( self )
self.cmd = cmd if cmd is None MSG.RUN_FUNCTION
self.data = data
def isDone( self ):
return self.isSet()
def join( self ):
self.wait( )
class Worker( threading.Thread ):
def __init__( self, console, queue, files_to_ignore ):
threading.Thread.__init__( self )
@ -225,8 +238,11 @@ class Worker( threading.Thread ):
( cmd, data ) = self.queue.get( )
if cmd == MSG.SHUTDOWN:
self.queue.task_done( )
self.console.flush( )
self.queue.task_done( )
break
if cmd == MSG.RUN_FUNCTION:
break
if cmd != MSG.PARSE_DIRECTORY or data is None: