我剛學Python和不循環與多線程很多經驗研究。我正嘗試通過請求session.post方法發送一些json。這在我需要運行字典的許多for循環的bottem函數中調用。的Python多線程一個具有有限線程
有沒有辦法讓使用並聯此運行?
我也有限制我的線程數,否則來電後得到阻止,因爲他們畢竟對方快。幫助將不勝感激。
def doWork(session, List, RefHashList):
for itemRefHash in RefHashList:
for equipment in res['Response']['data']['items']:
if equipment['itemHash'] == itemRefHash:
if equipment['characterIndex'] != 0:
SendJsonViaSession(session, getCharacterIdFromIndex(res, equipment['characterIndex']), itemRefHash, equipment['quantity'])
太棒了。感謝您提供快速而翔實的幫助。我可以在10秒內打250個電話,否則油門開始,我被阻止。現在我在10秒內發送大約10個電話。所以可能會有改進的潛力。 –
@LeoldeWire對'SendJsonViaSession'的調用實際上需要多長時間? –
〜0.3秒我會說 –