Skip to main content

Hi,

A Python based transformer has these three scaffold "defs": __init__(), input() and close().

"__init__" is called once when the transformer instance is initialized in the workflow. "input" is called for each feature, and "close" is called after the last feature has been sent (= when the workspace is done, I assume).

In case of a workspace crashing, the former two have a well-defined behaviour. But will "close()" be called for each transformer after a crash too ? Or is everything just thrown down the drain ?

I'm contemplating whether multiple transformers can share a common resource, but that only works if the resource in question is created/initialized once, and only disposed when all transformers have been closed. I.e. have had their "close()" routine called.

Cheers

Hi @lifalin2016, I don't think it's guaranteed that the "close" method would be called when the translation failed. How about initializing the resource in the startup script and disposing it in the shutdown script? The shutdown script would be definitely executed even if the translation failed unless the process crashed by unexpected error like memory overflow.


My understanding is that the close routine is called once all features have arrived at the transformer. This is not synonymous with the workspace being done.

If fme crashes, or there is a python exception error that terminates the translation in during the input, the close routine is not called.


Reply