Thread getting stuck\hang

Iranna Mathapati iranna.gani28 at gmail.com
Sat Apr 29 12:01:21 EDT 2017


Hi Dennis,

My requirement is like,i want to send the static and dynamic traffic
together.while traffic sending i want to delete some config from device.

st and dy both the targets want  to be  run at the same time.



On Fri, Apr 28, 2017 at 6:10 PM, Dennis Lee Bieber <wlfraed at ix.netcom.com>
wrote:

> On Fri, 28 Apr 2017 14:42:33 +0530, Iranna Mathapati
> <iranna.gani28 at gmail.com> declaimed the following:
>
> >Hi Dennis,
> >
> >Two threads(_st and _dy targets) sharing the same user define function at
> >the same  time...This is the reason for hang/stuck?
> >
> >in both the thread ,we are calling same user define function
> >(itgen_explorer.startTrafficFlows) and greping the values from return
> >function ,using it in main function.
> >
>
>         While the threads will have their own stacks, meaning function
> local
> data should be separate, if that common function is written anything like
> the st/dy threads (that is, full of "global" declarations) anything could
> be happening.
>
>
>         Given that your original sample main logic basically just started
> three
> threads and almost immediately waits for them to complete by using .join(),
> I have to wonder just why you are using threads at all.
>
>         Due to the GIL, even on a multi-core processor, only one thread can
> actually do anything at a time (threads work great when they spend most of
> their time waiting for I/O operations to complete, but are terrible if
> trying to do heavy number crunching). If you don't have lots of blocking
> I/O, the thread switching will actually make using threads take more time
> then just calling the functions one after the other.
>
>         From your original post, what happens if you replace:
>
> >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()
> >sniffer1.join()
> >sniffer2.join()
> >sniffer3.join()
>
> with just the inline calls:
>
> validate_traffic_stats_dy(the arg list)
> validate_traffic_stats_st(its arg list)
> delete_new_dynamic_nat_conf()
>
>         That should run them in sequence, with no chance for conflicts
> between
> shared state.
>
>         If you still get erratic hanging, you have a logic problem
> somewhere
> else in the program other than a shared state deadlock.
> --
>         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