how to share/access variables from multiprocessing target function

Iranna Mathapati iranna.gani28 at gmail.com
Wed May 3 10:04:15 EDT 2017


*Hi team,*

*How to access the multiprocessing  target function variables across the
main program. *

*def sending_static_traffic(FT_item_st,RT_item_st,pkt_st)*:
    log.info('Starting Static NAT forward Traffic Test...')
    global returndict_st_FP,returndict_st_RP   <<<<<<<<<<<How to
share/access these variable
    returndict_st_FP = itgen_explorer.startTrafficFlows(testbeddict,
log,'-traffic_items {0} -pktcount {1}  -profile
{2}'.format(FT_item_st,pkt_st,itgenProfile))
    time.sleep(10)
    log.info("Trafiic validation for NAT return path starting")
    returndict_st_RP = itgen_explorer.startTrafficFlows(testbeddict,
log,'-traffic_items {0} -pktcount 1000  -profile
{1}'.format(RT_item_st,itgenProfile))
    time.sleep(10)

*def sending_dynamic_traffic(FT_item_dy,RT_item_dy,pkt_dy_1):*
    log.info('Starting Dynamic NAT forward Traffic Test...')
    global returndict_dy_FP,returndict_dy_RP  <<<<<<< How to share/access
these variable
    returndict_dy_FP = itgen_explorer.startTrafficFlows(testbeddict,
log,'-traffic_items {0} -pktcount {1}  -profile
{2}'.format(FT_item_dy,pkt_dy_1,itgenProfile))
    time.sleep(10)
    log.info("Trafiic validation for NAT return path starting")
    returndict_dy_RP = itgen_explorer.startTrafficFlows(testbeddict,
log,'-traffic_items {0} -pktcount 1000  -profile
{1}'.format(RT_item_dy,itgenProfile))
    time.sleep(10)

sniffer1 = *multiprocessing.Process*(target=*sending_dynamic_traffic*,args
= (FT_item_dy,RT_item_dy,pkt_dy_1,arr,))
        sniffer2 =
*multiprocessing.Process*(target=*sending_static_traffic*,args
=(FT_item_st,RT_item_st,pkt_st,arr,))
        sniffer1.start()
        sniffer2.start()

how to share/access the " global returndict_st_FP,returndict_st_RP" target
function variables acors the  main program..


Thanks,
Iranna M



More information about the Python-list mailing list