0

I use a thread pool and and I submit some tasks to be proccessed.

Sometimes a server that I ping or my internet connection could be down. This can be determined by any of the running threads.

In that case I would like the thread that detected the error to notify the others to pause their execution until the error is fixed.

Do you know how is this possible?

I add to the above. The ideal solution would be : when a threads detects the program to send a message to all other threads to wait. Also it should notify an external server and after receiving that everything is ok from the server to send again a signal to the other threads to continue the work.

4

1 回答 1

2

我使用 threading.Event 找到了它

我只是有一个活动

event = Event()

我使用

event.wait()

一开始我

event.set()

当一个线程检测到错误时

event.clear()

并且线程正在等待直到

event.set()

这似乎有效

于 2012-06-29T12:51:32.197 回答