samedi 28 mars 2020

How to populate module internal progress status to another module?

let us say I have a python 3.7+ module/script A which does extensive computations. Furthermore, module A is being used inside another module B, where module A is fully encapsulated and module B doesn't know a lot of module's A internal implementation, just that it somehow outputs the progress of its computation.

Consider me as the responsible person (person A) for module A, and anyone else (person B) that doesn't know me, is writing module B. So person A is writing basically an open library.

What would be the best way of module A to output its progress? I guess it's a design decision.

  1. Would a getter in module A make sense so that module B has to always call this getter (maybe in a loop) in order to retrieve the progress of A?
  2. Would it possible to somehow use a callback function which is implemented in module A in such a way that this function is called every time the progress updates? So that this callback returns the current progress of A.
  3. Is there maybe any other approach to this that could be used?

Pointing me towards already existing solutions would be very helpful!

Aucun commentaire:

Enregistrer un commentaire