CentOS:Pythonスクリプトの実行中にピアエラーが原因で接続がリセットされました。

CentOS:Pythonスクリプトの実行中にピアエラーが原因で接続がリセットされました。

私は大学プロジェクトのためにPythonを使用してトラフィック生成ツールを作成しています。私はVmwareで独自のLinuxサーバーとクライアントを開発しました。私はPythonでトラフィックを生成するためにurllib2を使用しています。ここで直面する問題は、クライアントコンピュータでスクリプトを実行すると(マルチプロセッシングを使用してLinuxサーバーに要求を送信し続ける場合)、最初の数分間は正常に機能しますが、約2000件の要求が経過すると、「ピアへのリセット接続中」エラーが発生します。発生し、スクリプトが中断されました。何が問題なのでしょうか? ~しようとするこれしかし、それは役に立ちません。

このタイムアウトエラーを防ぎ、何時間もスクリプトを継続的に実行するにはどうすればよいですか?セントース6.5を使用しています

'''
Traffic Generator Script:
    Here I have used IP Aliasing to create multiple clients on single vm machine. same I have done on server side to create multiple servers. I have around 50 clients and 10 servers
'''
import multiprocessing
import urllib2
import random
import myurllist    #list of all destination urls for all 10 servers
import time
import socbindtry   #script that binds various virtual/aliased client ips to the script
response_time=[]    #some global variables shared between all processes
error_count=multiprocessing.Value('i',0)
def send_request3():    #function to send requests from alias client ip 1
    opener=urllib2.build_opener(socbindtry.BindableHTTPHandler3)    #bind to alias client ip1
    try:
    tstart=time.time()
    for i in range(myurllist.url):
        x=random.choice(myurllist.url[i])
        opener.open(x).read()
        print "file downloaded:",x
        response_time.append(time.time()-tstart)
    except urllib2.URLError, e:
        error_count.value=error_count.value+1
def send_request4():    #function to send requests from alias client ip 2
    opener=urllib2.build_opener(socbindtry.BindableHTTPHandler4)    #bind to alias client ip2
    try:
    tstart=time.time()
    for i in range(myurllist.url):
        x=random.choice(myurllist.url[i])
        opener.open(x).read()
        print "file downloaded:",x
        response_time.append(time.time()-tstart)
    except urllib2.URLError, e:
        error_count.value=error_count.value+1
#50 such functions are defined here for 50 clients
process=[]
def func():
    global process
    process.append(multiprocessing.Process(target=send_request3))
    process.append(multiprocessing.Process(target=send_request4))
    process.append(multiprocessing.Process(target=send_request5))
    process.append(multiprocessing.Process(target=send_request6))
#append 50 functions here
    for i in range(len(process)):
    process[i].start()
    for i in range(len(process)):
    process[i].join() 
    print"All work Done..!!"
    return
start=float(time.time())
func()
end=float(time.time())-start
print end

ベストアンサー1

おすすめ記事