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


Python Pool.add方法代码示例

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


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

示例1: testAdd

# 需要导入模块: from pool import Pool [as 别名]
# 或者: from pool.Pool import add [as 别名]
 def testAdd(self):
   results = set()
   pool = Pool(3)
   for result in pool.imap_unordered(Run, [[x] for x in range(0, 10)]):
     results.add(result.value)
     if result.value < 30:
       pool.add([result.value + 20])
   self.assertEquals(set(range(0, 10) + range(20, 30) + range(40, 50)),
                     results)
开发者ID:BazisSoft,项目名称:node-delphi,代码行数:11,代码来源:pool_unittest.py

示例2: runinpotok

# 需要导入模块: from pool import Pool [as 别名]
# 或者: from pool.Pool import add [as 别名]
def runinpotok(id_obzvon, type_obzvon):
    try:
#        model.from_number, model.id, filename, model.answer_dtmf, model.dtmf_wait_time, model.count_call, id_ivr
#        from_numb = sys.argv[1]
#        id_obzvon = sys.argv[1]
#        file = sys.argv[3]
#        dtmf = sys.argv[4]
#        wait_dtmf = sys.argv[5]
#        count_call = sys.argv[6]
#        number_ivr = sys.argv[7]
#        type_obzvon = sys.argv[2]

        #from ConfigParser import ConfigParser

        #config = ConfigParser()
        #config.read('/usr/local/freeswitch/python/config.ini')
        """Data for connect to database ebs"""
        #HOST = config.get('db', 'host')
        #USER = config.get('db', 'user')
        #PASSWORD = config.get('db', 'password')
        #DBNAME = config.get('db', 'dbname')
        print "connect to db in potok"
        print DATABASES['billing']['HOST']
        conn = psycopg2.connect("dbname=%s user=%s host=%s password=%s" % (DATABASES['billing']['NAME'], DATABASES['billing']['USER'], DATABASES['billing']['HOST'], DATABASES['billing']['PASSWORD']));
        conn.set_isolation_level(0)
        cur = conn.cursor()
        id_copy = id_obzvon
        if type_obzvon == 'repeat':
            cur.execute("""INSERT INTO user_obzvon (billing_account_id, from_number, file,file_text,status,answer_dtmf,answer_ivr,dtmf_wait_time,count_call,one_times,
                            obzvon_time_for_one,date_to,many_times,obzvon_time_enabled,obzvon_time,obzvon_day_enabled,day_of_week,obzvon_concretic_day_enabled,day_of_month)
                            SELECT billing_account_id, from_number, file,file_text,status,answer_dtmf,answer_ivr,dtmf_wait_time,count_call,one_times,
                            obzvon_time_for_one,date_to,many_times,obzvon_time_enabled,obzvon_time,obzvon_day_enabled,day_of_week,obzvon_concretic_day_enabled,
                            day_of_month FROM user_obzvon WHERE id=%s RETURNING id;""" % (id_obzvon,))
            print """INSERT INTO user_obzvon (billing_account_id, from_number, file,file_text,status,answer_dtmf,answer_ivr,dtmf_wait_time,count_call,one_times,
                            obzvon_time_for_one,date_to,many_times,obzvon_time_enabled,obzvon_time,obzvon_day_enabled,day_of_week,obzvon_concretic_day_enabled,day_of_month)
                            SELECT billing_account_id, from_number, file,file_text,status,answer_dtmf,answer_ivr,dtmf_wait_time,count_call,one_times,
                            obzvon_time_for_one,date_to,many_times,obzvon_time_enabled,obzvon_time,obzvon_day_enabled,day_of_week,obzvon_concretic_day_enabled,
                            day_of_month FROM user_obzvon WHERE id=%s RETURNING id;""" % (id_obzvon,)
            print 'id_copy'

            id_copy = cur.fetchone()[0]
            print id_copy

        cur.execute("""UPDATE user_obzvon SET status = 3 where id='%s';""" % (id_copy))

        cur.execute("""SELECT from_number, file, answer_dtmf, dtmf_wait_time, count_call, s.create_myivr_temp_id, min_time, max_time, max_min_time_enabled
                    FROM user_obzvon LEFT JOIN user_obzvon_obzvon_ivr s ON s.obzvonmodel_id=%s WHERE user_obzvon.id=%s;""" % (id_obzvon,id_obzvon,))
        list_variable = cur.fetchone()
        cur.execute("""SELECT id, number, add_number FROM user_obzvon_number WHERE id_obzvon_id=%s AND status=''""" % (id_obzvon,))
        if type_obzvon == 'repeat':
            cur.execute("""SELECT id, number, add_number FROM user_obzvon_number WHERE id_obzvon_id=%s""" % (id_obzvon,))
        else:
            cur.execute("""SELECT id, number, add_number FROM user_obzvon_number WHERE id_obzvon_id=%s AND status=''""" % (id_obzvon,))
        List = cur.fetchall()
        print List
        pool = Pool(workers=10 if len(List) > 10 else len(List), acceleration=5)
        for x in List:
            i = x[0]
            if type_obzvon == 'repeat':
                cur.execute("""INSERT INTO user_obzvon_number (billing_account_id,number,add_number,status,
                                answer_time,duration,id_obzvon_id,digits,number_from_file)
                                SELECT billing_account_id,number,add_number,status,answer_time,duration,%s,
                                digits,number_from_file FROM user_obzvon_number WHERE id=%s RETURNING id;""" % (id_copy,x[0],))
                id_number_copy = cur.fetchone()
                print "id_number_copy"
                print id_number_copy[0]
                i = id_number_copy[0]
            add = x[2]
            sim = x[1]

            #pool.add(take_event, from_numb, str(sim), str(add), file, id_copy, i, cur, dtmf, wait_dtmf, count_call, number_ivr)
            pool.add(take_event, list_variable[0], str(sim), str(add), list_variable[1], id_copy, i, cur, list_variable[2], list_variable[3], list_variable[4], list_variable[5], list_variable[6], list_variable[7], list_variable[8])
        pool.start(wait_threads=False)

    except Exception, e:
        print e
开发者ID:varikgit,项目名称:globalhome_ats,代码行数:78,代码来源:potok_for_obzvon.py


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