在python2.7中的同一个python脚本中多次同时运行相同的python模块

时间:2017-10-06 10:26:55

标签: python-2.7 asynchronous

所以我需要一种同时运行多次的方法,同时异步同一模块。我知道在python 3中有asynco的东西,但是如何在python 2中做到这一点?有什么想法吗?

这是代码示例:

MainPython.py

insert into ' +@DB + '.[Tforms](id, [tablename])
     select max_id + row_number() over (order by id) as id, @newtbn
     from (select t.*, max(id) over () as max_id
           from '+ @DB+ '.[Tforms] t
          ) t
     where tid = ' +str(@sourcetid) ;

SecondPython.py

from SecondPython import Single
mydata = {"1": {"stat": ""}, "2": {"stat": "1"}, "3": {"stat": ""}}
cnt = 0
for i in range(len(mydata.keys())):
    result = Single(mydata, "browser")
    if result == 101:
        print "do this"
        cnt += 1
        if cnt >= 5:
           break
    else:
        print "do thata"

0 个答案:

没有答案