Skip to main content
Solved

Python based transformer cleanup ?


lifalin2016
Contributor
Forum|alt.badge.img+29

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

Best answer by jdh

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.

View original
Did this help you find an answer to your question?

2 replies

takashi
Evangelist
  • January 11, 2017

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.


jdh
Contributor
Forum|alt.badge.img+28
  • Contributor
  • Best Answer
  • January 11, 2017

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.


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings