Thread getting stuck\hang

Iranna Mathapati iranna.gani28 at gmail.com
Thu Apr 27 12:46:06 EDT 2017


Hi Dennis,

all function arguments declare as global and pass it to the function.

All three thread is completed the execution part and after completion of
execution its stuck/hang the programme.

*def
validate_traffic_stats_st(FT_item,RT_item,forward_path_list,return_path_list,nat_type_list,pkt_st)*
:
    global flag1
    flag1 = 1

    log.info('Starting Static NAT forward Traffic Test...')

    returndict = itgen_explorer.startTrafficFlows(testbeddict,
log,'-traffic_items {0} -pktcount {1}  -profile
{2}'.format(FT_item,pkt_st,itgenProfile))
    time.sleep(5)
    global_stats_list = []
    temp = 0
    forward_ip_list = []
    return_ip_list = []
    global count_st_Rx,count_st_in_Rx,count_st_out_Rx
    count_st_Rx = 0
    count_st_in_Rx = 0
    count_st_out_Rx = 0
    for data in returndict['txrxstats']['rx'].keys():
        if "TI01" in data:
            count_st_Rx += int(returndict['txrxstats']['rx'][data] )
            count_st_in_Rx += int(returndict['txrxstats']['rx'][data] )
        elif "TI22" in data:
            count_st_Rx += int(returndict['txrxstats']['rx'][data] )
            count_st_out_Rx += int(returndict['txrxstats']['rx'][data] )

    global count_st_Tx,count_st_in_Tx,count_st_out_Tx
    count_st_Tx = 0
    count_st_in_Tx = 0
    count_st_out_Tx = 0

    for data in returndict['txrxstats']['tx'].keys():
        if "TI01" in data:
            count_st_Tx += int(returndict['txrxstats']['tx'][data] )
            count_st_in_Tx += int(returndict['txrxstats']['tx'][data] )
        elif "TI22" in data:
            count_st_Tx += int(returndict['txrxstats']['tx'][data] )
            count_st_out_Tx += int(returndict['txrxstats']['tx'][data] )


    for forward_ip_list,return_ip_list,nat_type in zip
(forward_path_list,return_path_list,nat_type_list):
        global_stats_list = []
        for translation_ip,return_ip in zip
(forward_ip_list,return_ip_list):
            output=listtostr(returndict['txrxstats']['rx'])
            if re.search('{0}'.format(translation_ip),output,re.I):
                pass
            else:
                global_stats_list.append(translation_ip)
        if global_stats_list == []:
            log.info('itgen traffic validation for {0} forward path -
verified'.format(nat_type))
            forward_ip_list = []
            return_ip_list = []
        else:
            log.error('{0} forward path itgen verification
failed'.format(nat_type))
            flag1 = 0
            return flag1
    log.info("Trafiic validation for NAT return path starting")
    returndict = itgen_explorer.startTrafficFlows(testbeddict,
log,'-traffic_items {0} -pktcount 1000  -profile
{1}'.format(RT_item,itgenProfile))
    time.sleep(5)
    local_stats_list = []
    for forward_ip_list,return_ip_list,nat_type in zip
(forward_path_list,return_path_list,nat_type_list):
        local_stats_list = []
        for translation_ip,return_ip in zip
(forward_ip_list,return_ip_list):
            output=listtostr(returndict['txrxstats']['rx'])
            if re.search('{0}'.format(return_ip),output,re.I):
                pass
            else:
                local_stats_list.append(return_ip)
        if local_stats_list == []:
            log.info('itgen traffic validation for {0} return path -
verified'.format(nat_type))
            forward_ip_list = []
            return_ip_list = []
        else:
            log.error('{0} return path itgen verification
failed'.format(nat_type))
            flag1 = 0
            return flag1

    return
flag1,count_st_Rx,count_st_in_Rx,count_st_out_Rx,count_st_Tx,count_st_in_Tx,count_st_out_Tx

*def
validate_traffic_stats_dy(FT_item,RT_item,forward_path_list,return_path_list,nat_type_list,pkt_dy_1):*
    global flag2
    flag2 = 1
    log.info('Starting Dynamic NAT forward Traffic Test...')

    returndict = itgen_explorer.startTrafficFlows(testbeddict,
log,'-traffic_items {0} -pktcount {1}  -profile
{2}'.format(FT_item,pkt_dy_1,itgenProfile))
    time.sleep(5)
    global_stats_list = []
    forward_ip_list = []
    return_ip_list = []
    global count_dy_Rx,count_dy_in_Rx,count_dy_out_Rx
    count_dy_Rx = 0
    count_dy_in_Rx = 0
    count_dy_out_Rx = 0
    for data in returndict['txrxstats']['rx'].keys():
        if "TI05" in data:
            count_dy_Rx += int(returndict['txrxstats']['rx'][data] )
            count_dy_in_Rx += int(returndict['txrxstats']['rx'][data] )
        elif "TI66" in data:
            count_dy_Rx += int(returndict['txrxstats']['rx'][data] )
            count_dy_out_Rx += int(returndict['txrxstats']['rx'][data] )

    global count_dy_Tx,count_dy_in_Tx,count_dy_out_Tx
    count_dy_Tx = 0
    count_dy_in_Tx = 0
    count_dy_out_Tx = 0
    for data in returndict['txrxstats']['tx'].keys():
        if "TI05" in data:
            count_dy_Tx += int(returndict['txrxstats']['tx'][data] )
            count_dy_in_Tx += int(returndict['txrxstats']['tx'][data] )
        elif "TI66" in data:
            count_dy_Tx += int(returndict['txrxstats']['tx'][data] )
            count_dy_out_Tx += int(returndict['txrxstats']['tx'][data] )

    for forward_ip_list,return_ip_list,nat_type in zip
(forward_path_list,return_path_list,nat_type_list):
        global_stats_list = []
        for translation_ip,return_ip in zip
(forward_ip_list,return_ip_list):
            output=listtostr(returndict['txrxstats']['rx'])
            if re.search('{0}'.format(translation_ip),output,re.I):
                pass
            else:
                global_stats_list.append(translation_ip)
        if global_stats_list == []:
            log.info('itgen traffic validation for {0} forward path -
verified'.format(nat_type))
            forward_ip_list = []
            return_ip_list = []
        else:
            log.error('{0} forward path itgen verification
failed'.format(nat_type))
            flag2 = 0
            return flag2
    log.info("Trafiic validation for NAT return path starting")
    returndict = itgen_explorer.startTrafficFlows(testbeddict,
log,'-traffic_items {0} -pktcount 1000  -profile
{1}'.format(RT_item,itgenProfile))
    time.sleep(5)
    local_stats_list = []
    for forward_ip_list,return_ip_list,nat_type in zip
(forward_path_list,return_path_list,nat_type_list):
        local_stats_list = []
        for translation_ip,return_ip in zip
(forward_ip_list,return_ip_list):
            output=listtostr(returndict['txrxstats']['rx'])
            if re.search('{0}'.format(return_ip),output,re.I):
                pass
            else:
                local_stats_list.append(return_ip)
        if local_stats_list == []:
            log.info('itgen traffic validation for {0} return path -
verified'.format(nat_type))
            forward_ip_list = []
            return_ip_list = []
        else:
            log.error('{0} return path itgen verification
failed'.format(nat_type))
            flag2 = 0
            return flag2
    return
flag2,count_dy_Rx,count_dy_in_Rx,count_dy_out_Rx,count_dy_Tx,count_dy_in_Tx,count_dy_out_Tx

*def* *delete_new_dynamic_nat_conf():*
    global pool_dy_in_new,acl_name_dy_in_new,pool_name_dy_in_new
    direction_in = 'inside'
    log.info("Deleting Dynamic NAT new entries")
    delete_dynamic_nat_conf(uut2_hdl2, direction_in,
                            acl_name_dy_in_new,
                            pool_name_dy_in_new,
                            )
    #remove pool and acl name
    log.info('Removing access-list')
    deleteACL(uut2_hdl2, log, '-type {0} -name {1}'.format('ip',
acl_name_dy_in_new))
    log.info('Unconfiguring pool on UUT')
    add_remove_pool(uut2_hdl2, 'unconfigure', pool_dy_in_new)
    return 1

On Thu, Apr 27, 2017 at 9:04 PM, Dennis Lee Bieber <wlfraed at ix.netcom.com>
wrote:

> On Thu, 27 Apr 2017 19:48:24 +0530, Iranna Mathapati
> <iranna.gani28 at gmail.com> declaimed the following:
>
> >Hi Team,
> >
> >I have python code that creates  thread.Sometimes it works, sometimes it
> >gets stuck once its finish its execution part. still not yet cannot find
> >any difference between when it works or when it gets stuck. Please help.
> >
> >
> >sniffer1 =
> >threading.Thread(target=validate_traffic_stats_dy,
> args=(FT_item_dy,RT_item_dy,forward_path_list_dy,return_
> path_list_dy,nat_type_list_dy,pkt_dy_1,))
> >
> >sniffer2 =
> >threading.Thread(target=validate_traffic_stats_st,
> args=(FT_item_st,RT_item_st,forward_path_list_st,return_
> path_list_st,nat_type_list_st,pkt_st,))
> >
> >sniffer1.start()
> >
> >sniffer2.start()
> >
> >sniffer3 = threading.Thread(target=delete_new_dynamic_nat_conf)
> >
> >sniffer3.start()
> >
>
>         So where is the code for the three thread functions? Where do the
> various argument values come from?
> --
>         Wulfraed                 Dennis Lee Bieber         AF6VN
>     wlfraed at ix.netcom.com    HTTP://wlfraed.home.netcom.com/
>
> --
> https://mail.python.org/mailman/listinfo/python-list
>


More information about the Python-list mailing list