python - Processes in multiprocessing.Pool not reporting runtime errors -
I have a pool of processes in Python that has been used from How can I get those errors in the errors of the pool report and if something goes wrong, then what can be terminated? In order for you to be raised in the parent, the actual You can execute any In Python 3.2+, the keyword argument was introduced, which allows you to pass a callback that is executed if the worker is in a Exception is picked up, but you can not do that in Python 2.x What you can do is to wrap your worker's work in adopting any exception, instead of lifting it into return worker in except Then you will get a normal callback The function that checks to see if the multiprocessing import pool . I run various tasks to pass those people, calling the
Pool.apply_async function. If I start one of those errors (i.e.: a line of code, such as
5/0 ), expected command line report
ZeroVision Aire: Zero by integer division or modules Never shows, and the program never ends, even if I present a callback function in the call to "Code.Apple_async , I never called the callback function. Goes, if the function is done To Anvit is an error on that.
apply_async (Or
map_async ), try the returned results.
def func (): Exception ("we failed") ... results = pool.app_a_sync (funk, args = (arg)) time.sleep (2) result.get ( ) # Exception is only picked here.
callback only function if the function returns successfully. If it raises an exception, it is abandoned
try /
block. . :
def func (): try: Exception exception ("we fail") Exception e: Return e
exception was returned:
def callback (result): ifinstance (result, exception): # Also have to clean and exit: # function was successful
Comments
Post a Comment