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


Python Client.wait方法代码示例

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


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

示例1: IPClusterEnsemble

# 需要导入模块: from ipyparallel import Client [as 别名]
# 或者: from ipyparallel.Client import wait [as 别名]
class IPClusterEnsemble(SurveyEnsemble):
    """
    Parallelized suvey ensemble based on IPython parallal (ipcluster)

    Args: 
        \*\*specs: 
            user specified values
            
    Attributes: 
        

    Notes:  

    """

    def __init__(self, **specs):

        SurveyEnsemble.__init__(self, **specs)

        # access the cluster
        self.rc = Client()
        self.dview = self.rc[:]
        self.dview.block = True
        with self.dview.sync_imports(): import EXOSIMS,EXOSIMS.util.get_module
        r1 = self.dview.execute("SurveySim = EXOSIMS.util.get_module.get_module('%s', 'SurveySimulation')"%specs['modules']['SurveySimulation'])
        self.dview.push(dict(specs=specs))
        r2 = self.dview.execute("sim = SurveySim(**specs)")
        self.lview = self.rc.load_balanced_view()

    def run_ensemble(self,run_one,N=10):
        t1 = time.time()
        async_res = []
        for j in range(N):
            ar = self.lview.apply_async(run_one)
            async_res.append(ar)

        print "Submitted tasks: ", len(async_res)
        
        self.rc.wait(async_res)
        t2 = time.time()
        print "Completed in %d sec" %(t2-t1)

        res = [ar.get() for ar in async_res]

        return res
开发者ID:ChrisDelaX,项目名称:EXOSIMS,代码行数:47,代码来源:IPClusterEnsemble.py

示例2: connect_client

# 需要导入模块: from ipyparallel import Client [as 别名]
# 或者: from ipyparallel.Client import wait [as 别名]
 def connect_client(self):
     """connect a client with my Context, and track its sockets for cleanup"""
     c = Client(profile='iptest', context=self.context)
     c.wait = lambda *a, **kw: self.client_wait(c, *a, **kw)
     
     for name in filter(lambda n:n.endswith('socket'), dir(c)):
         s = getattr(c, name)
         s.setsockopt(zmq.LINGER, 0)
         self.sockets.append(s)
     return c
开发者ID:CaptainAL,项目名称:Spyder,代码行数:12,代码来源:clienttest.py

示例3: par_value

# 需要导入模块: from ipyparallel import Client [as 别名]
# 或者: from ipyparallel.Client import wait [as 别名]
def par_value(n):
    """
    Parallel option valuation

    Parameters
    ==========
    n: int
        number of option valuations/strikes
    """
    import numpy as np
    from ipyparallel import Client
    
    c = Client(profile="default")
    view = c.load_balanced_view()

    strikes = np.linspace(80, 20, n)
    option_values = []
    for strike in strikes:
        values = view.apply_async(bsm_mcs_valuation, strike)
        option_values.append(values)
    c.wait(option_values)
    return strikes, option_values
开发者ID:UID1,项目名称:My-First-Repo-14,代码行数:24,代码来源:mcparalleltut2.py

示例4: client_wait

# 需要导入模块: from ipyparallel import Client [as 别名]
# 或者: from ipyparallel.Client import wait [as 别名]
 def client_wait(self, client, jobs=None, timeout=-1):
     """my wait wrapper, sets a default finite timeout to avoid hangs"""
     if timeout < 0:
         timeout = self.timeout
     return Client.wait(client, jobs, timeout)
开发者ID:CaptainAL,项目名称:Spyder,代码行数:7,代码来源:clienttest.py


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