parameters: (taskHandles, logger = None, interactive=True, quitKey='q',
                                      sleepTime=20)
return_statement: return
docstring: Block in this function until the user presses a key or all tasks complete.
docstring_summary: Block in this function until the user presses a key or all tasks complete.
docstring_tokens: Block in this function until the user presses a key or all tasks complete .
function: def waitForTaskCompletionOrKeypress(taskHandles, logger = None, interactive=True, quitKey='q',
                                      sleepTime=20):
      '''Block in this function until the user presses a key or all tasks complete.'''
  
      # Wait for all the tasks to complete
      notReady = len(taskHandles)
      while notReady > 0:
  
          if interactive:
              # Wait and see if the user presses a key
              msg = 'Waiting on ' + str(notReady) + ' process(es), press '+str(quitKey)+'<Enter> to abort...\n'
              keypress = nonBlockingRawInput(prompt=msg, timeout=sleepTime)
              if keypress == quitKey:
                  logger_print(logger, 'Recieved quit command!')
                  break
          else:
              logger_print(logger, "Waiting on " + str(notReady) + ' incomplete tasks.')
              time.sleep(sleepTime)
              
          # As long as we have this process waiting, keep track of our resource consumption.
          cpuPercentUsage = psutil.cpu_percent()
          memInfo         = psutil.virtual_memory()
          memUsed         = memInfo[0] - memInfo[1]
          memPercentUsage = float(memUsed) / float(memInfo[0])
  
          usageMessage = ('CPU percent usage = %f, Memory percent usage = %f' 
                          % (cpuPercentUsage, memPercentUsage))
          logger_print(logger, usageMessage)
              
          # Otherwise count up the tasks we are still waiting on.
          notReady = 0
          for task in taskHandles:
              if not task.ready():
                  notReady += 1
      return
function_tokens: def waitForTaskCompletionOrKeypress ( taskHandles , logger = None , interactive = True , quitKey = 'q' , sleepTime = 20 ) : # Wait for all the tasks to complete notReady = len ( taskHandles ) while notReady > 0 : if interactive : # Wait and see if the user presses a key msg = 'Waiting on ' + str ( notReady ) + ' process(es), press ' + str ( quitKey ) + '<Enter> to abort...\n' keypress = nonBlockingRawInput ( prompt = msg , timeout = sleepTime ) if keypress == quitKey : logger_print ( logger , 'Recieved quit command!' ) break else : logger_print ( logger , "Waiting on " + str ( notReady ) + ' incomplete tasks.' ) time . sleep ( sleepTime ) # As long as we have this process waiting, keep track of our resource consumption. cpuPercentUsage = psutil . cpu_percent ( ) memInfo = psutil . virtual_memory ( ) memUsed = memInfo [ 0 ] - memInfo [ 1 ] memPercentUsage = float ( memUsed ) / float ( memInfo [ 0 ] ) usageMessage = ( 'CPU percent usage = %f, Memory percent usage = %f' % ( cpuPercentUsage , memPercentUsage ) ) logger_print ( logger , usageMessage ) # Otherwise count up the tasks we are still waiting on. notReady = 0 for task in taskHandles : if not task . ready ( ) : notReady += 1 return