dictionary of pickle error when get it in multiprocessing and has name error

Ho Yeung Lee jobmattcon at gmail.com
Sun Feb 26 23:08:51 EST 2017


before cloususerlogin
Unexpected error: <type 'exceptions.NameError'>
after map pool


...
passwordlist = pickle.load( open( str(currentworkingdirectory) + "\\decryptedsecret.p", "rb" ) )

def processInput(host):
    try:
        decrypt_file(sys.argv[1], str(currentworkingdirectory) + "\\encryptedsecret.p", str(currentworkingdirectory) + "\\decryptedsecret.p", 64*1024)
        if os.path.isfile(str(currentworkingdirectory) + "\\decryptedsecret.p") == True:
            print("exist file")
        else:
            print("not exist file")
        print(str(currentworkingdirectory) + "\\decryptedsecret.p")
        HOST = host 
        print(host)
        print("before cloususerlogin")
        password = passwordlist["clouduserlogin"]                 <--------------- Name error
        print(host)
        text_file.write(host+"\n") 
        try:
            print("before recursiveconnect")
            recursiveconnect(host,"")
            print("after recursiveconnect")
        except:
            print "inner Unexpected error:", sys.exc_info()[0] 
    except:
        print "Unexpected error:", sys.exc_info()[0]
        resultstringedge = ""



def easy_parallize():
    pool = Pool(4)
    print("after pool")
    hostlist = [
    "192.168.1.1"
    ]
    #foo = Foo()
    #results = pool.apply_async(processInput,args=(hostlist,))
    results = pool.map(processInput, hostlist)
    print("after map pool")
    cleaned = [x for x in results if not x is None]
    cleaned = np.asarray(cleaned)
    pool.close()
    pool.join()
    print("cleaned")
    return cleaned

if __name__ == '__main__':
    currentworkingdirectory = str(os.getcwd()).replace("\\","\\\\")
    text_file = open(newpath+"\\"+"errorstest.txt", "w")
    easy_parallize()  
    print("111")  
    #for host in hostlist:
    #if os.path.isfile(str(currentworkingdirectory) + "\\decryptedsecret.p") == True:
        #try:
            #os.remove(str(currentworkingdirectory) + "\\decryptedsecret.p")
        #except:
            #print("ignored error")
    print("here close 1")
    text_file.close()
    print("here close 2")
    text_file10.close()



More information about the Python-list mailing list