示例#1
0
    def do_command():
        
        while len(outputs) < args.num_outputs:
             yield asyncio.From(asyncio.sleep(1.0))
      
        output = mFI.output(args.output)
       
        if not output:
            print ("output {} does not exist".format(args.output))
            return
        
        while not output.ready:
            yield asyncio.From(asyncio.sleep(1.0))

        if args.on:
            output.output = True
            while not output.output:
                yield asyncio.From(asyncio.sleep(0.5))

        elif args.off:
            output.output = False
            while output.output == True:
                yield asyncio.From(asyncio.sleep(0.5))
                
        else:
            while True:
                yield asyncio.From(asyncio.sleep(0.5))
示例#2
0
def _work(task, result_queue, no_result, all_result):
    try:
        result = yield asyncio.From(task)
    except Result as e:
        result = e.result
    except Exception as e:
        import traceback
        logger.warning('async exception: {e}\n {trace}'.format(
            e=e, trace=traceback.format_exc()))
        result = None

    if no_result:
        return
    if all_result:
        result_queue.put(result)
    else:
        if result:
            result_queue.put(result)
示例#3
0
 def handle_timeout(self):
     while True:
         yield asyncio.From(asyncio.sleep(self.getTimerResolution()))
         self.handleTimerTick(loop.time())