Parallel Python: What is a callback?

后端 未结 5 1537
别跟我提以往
别跟我提以往 2020-12-04 07:27

In Parallel Python it has something in the submit function called a callback (documentation) however it doesn\'t seem to explain it too well. I\'ve posted on

5条回答
  •  春和景丽
    2020-12-04 08:10

    Looking at the link, just looks like a hook which is called.

    callback - callback function which will be called with argument list equal to callbackargs+(result,) as soon as calculation is done

    The "as soon as calculation is done" bit seems ambiguous. The point, as far as I can see of this thing is that the submit() call distributes work to other servers and then returns. Because the finishing is asynchronous, rather block, it allows you to provide a function which is called when some unit of work finishes. If you do:

    submit( ..., callback=work_finished, ... )
    

    Then submit will ensure work_finished() is called when the unit of distributed work is completed on the target server.

    When you call submit() you can provide a callback which is called in the same runtime as the caller of submit() ... and it is called after the distribution of the workload function is complete.

    Kind of like "call foo(x,y) when you have done some stuff in submit()"

    But yea, the documentation could be better. Have a ganders at the ppython source and see at which point the callback is called in submit()

提交回复
热议问题