Thread getting stuck\hang
iranna.gani28 at gmail.com
Sat Apr 29 12:01:21 EDT 2017
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>
> 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
> 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
> 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 =
> >sniffer2 =
> >sniffer3 = threading.Thread(target=delete_new_dynamic_nat_conf)
> with just the inline calls:
> validate_traffic_stats_dy(the arg list)
> validate_traffic_stats_st(its arg list)
> That should run them in sequence, with no chance for conflicts
> shared state.
> If you still get erratic hanging, you have a logic problem
> 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/
More information about the Python-list