Adding new worker run type
This commit is contained in:
parent
3ffdd76147
commit
6236ead338
|
@ -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:
|
||||
|
|
Loading…
Reference in New Issue