当前位置: 首页>>代码示例>>Python>>正文


Python Task.outbox方法代码示例

本文整理汇总了Python中Task.Task.outbox方法的典型用法代码示例。如果您正苦于以下问题:Python Task.outbox方法的具体用法?Python Task.outbox怎么用?Python Task.outbox使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Task.Task的用法示例。


在下文中一共展示了Task.outbox方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __call__

# 需要导入模块: from Task import Task [as 别名]
# 或者: from Task.Task import outbox [as 别名]
    def __call__(self,inputs,function=None):
        
        # could get expensive with lots of __call__
        local_queue = self.local_queue
        
        if not isinstance(inputs,Task):
            this_task = Task( inputs   = inputs ,
                              function = function ,
                              outbox   = local_queue )
        else:
            this_task = inputs
            this_task.outbox = local_queue
        
        self.put(this_task)

        task = local_queue.get(block=True)
        
        outputs = task.outputs
        
        return outputs
开发者ID:aerialhedgehog,项目名称:VyPy,代码行数:22,代码来源:Remote.py

示例2: __run__

# 需要导入模块: from Task import Task [as 别名]
# 或者: from Task.Task import outbox [as 别名]

#.........这里部分代码省略.........
                 sys.stderr.write( traceback.format_exc() )
                 sys.stderr.write( '\n' )
                 sys.stderr.flush()
             continue
         
         # report
         if self.verbose: print '%s: Got task' % name; sys.stdout.flush()
         
         # --------------------------------------------------------------
         #   Execute Task
         # --------------------------------------------------------------
         try:
             # check task object type
             if not isinstance(this_task,Task):
                 #raise Exception, 'Task must be of type VyPy.Task'
                 this_task = Task(this_task,self.function)
             
             # unpack task
             this_input    = this_task.inputs
             this_function = this_task.function or self.function
             this_owner    = this_task.owner
             this_folder   = this_task.folder
             
             # --------------------------------------------------------------
             #   Check for kill signal
             # --------------------------------------------------------------
             if isinstance(this_input,KillTask.__class__):
                 break
             
             # report
             if self.verbose: print '%s: Inputs = %s, Operation = %s' % (name,this_input,self.function); sys.stdout.flush()
             
             # --------------------------------------------------------------
             #   Call Task Function
             # --------------------------------------------------------------
             # in the folder it was created
             with redirect.folder(this_folder):
                 # report
                 if self.verbose: print os.getcwd(); sys.stdout.flush()
                 
                 # the function call!
                 this_output = self.__func__(this_input,this_function)
             
             # report
             if self.verbose: print '%s: Task complete' % name; sys.stdout.flush()                
             
             # make sure we get std's
             sys.stdout.flush()
             sys.stderr.flush()
         
         # --------------------------------------------------------------
         #   Task Exception Catching
         # --------------------------------------------------------------
         # system exits
         except (KeyboardInterrupt, SystemExit):
             raise
         # all other exceptions
         except Exception as exc:
             trace_str = traceback.format_exc()
             if self.verbose: 
                 sys.stderr.write( '%s: Task Failed \n' % name )
                 sys.stderr.write( trace_str )
                 sys.stderr.write( '\n' )
                 sys.stderr.flush()
             exc.args = (trace_str,)
             this_output = exc
             
         #: end try task
         
         # --------------------------------------------------------------
         #   Wrap Up Task
         # --------------------------------------------------------------
         
         # store output
         this_task.outputs = this_output            
         
         # pick outbox
         this_outbox = this_task.outbox or self.outbox
         # avoid serialization error with managed outboxes
         this_task.outbox = None 
         
         # put task
         if this_outbox: this_outbox.put(this_task)
         
         # end joinable inbox task
         self.inbox.task_done()
         
     #: end while alive
     
     # --------------------------------------------------------------
     #   End of Process
     # --------------------------------------------------------------
     
     # end joinable inbox task
     self.inbox.task_done()
     
     # report
     if self.verbose: print '%s: Ending' % name; sys.stdout.flush()
     
     return
开发者ID:jiaxu825,项目名称:VyPy,代码行数:104,代码来源:Service.py


注:本文中的Task.Task.outbox方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。