Skip to main content

I'm trying to configure a python shutdown script to run if a user cancels a workflow prematurely. In testing I'm finding that the scrips does not run (or at least it appears not to run).

 

 

Is this expected behavior? Has anyone been able to work around this? @DebbiAtSafe any ideas?

 

 

The limitation here is when working with live streams - The process will never end until terminated/cancelled.

 

 

Cheers

I can think of a workaround, but it's nothing pretty. Whatever "receiver" transformer you are using, instead of stopping it manually, send a final message to it with the message "STOP". Then a Tester tests to see if it is a STOP message and, if so, runs a PythonCaller then a Terminator transformer.

Even less pretty, instead of a final message to the WhateverReceiver, send each real message to a DropboxConnector. It gets a list of files and if STOP.TXT is there, then it runs the PythonCaller/Terminator.

Instead of Dropbox you could do things like Twitter, Email, Database record etc. Just some sort of flag somewhere that says to run the Python and then stop the translation. But unless it is its own receiver, you'll only have it run when the WhateverReceiver receives a message.

Alternatively, when you start the workspace, get the process ID and send it to... another workspace or Python script. Something that can monitor for when the process ID dies and act on it.

Hope this helps. I know none of these are very elegant, but they are all I can think of at the moment.


I can think of a workaround, but it's nothing pretty. Whatever "receiver" transformer you are using, instead of stopping it manually, send a final message to it with the message "STOP". Then a Tester tests to see if it is a STOP message and, if so, runs a PythonCaller then a Terminator transformer.

Even less pretty, instead of a final message to the WhateverReceiver, send each real message to a DropboxConnector. It gets a list of files and if STOP.TXT is there, then it runs the PythonCaller/Terminator.

Instead of Dropbox you could do things like Twitter, Email, Database record etc. Just some sort of flag somewhere that says to run the Python and then stop the translation. But unless it is its own receiver, you'll only have it run when the WhateverReceiver receives a message.

Alternatively, when you start the workspace, get the process ID and send it to... another workspace or Python script. Something that can monitor for when the process ID dies and act on it.

Hope this helps. I know none of these are very elegant, but they are all I can think of at the moment.

Thanks for the suggestions @Mark2AtSafe, I think I might try getting the fme pid and passing that to a workspace to monitor as you suggested. But you're right it's not really pretty.

 

 

I've created an idea here for others to vote on: https://knowledge.safe.com/idea/87965/shutdown-scripts-to-run-even-if-the-process-is-abo.html?

 

 

 

 

 


Hi @virtualcitymatt

Mark has already suggested some workarounds so I'm going to address the expected behaviour part of your question.

I believe a shutdown script not executing if a translation is aborted by the user is expected behaviour.

As mentioned in the documentation here, the shutdown script runs after the translation has completed either successfully or prematurely. When the Stop tool is used (ie. Translation ABORTED), FME kills the process immediately. The translation does not get the chance to complete and so the shutdown script does not run.

If the translation ends due to an error (ie. Translation FAILED due to rejected feature or Terminator), the shutdown script runs as the translation does complete--cleanup is done, readers and writers are shut down, and log file is closed.

I hope this information helps.


Hi @virtualcitymatt

Mark has already suggested some workarounds so I'm going to address the expected behaviour part of your question.

I believe a shutdown script not executing if a translation is aborted by the user is expected behaviour.

As mentioned in the documentation here, the shutdown script runs after the translation has completed either successfully or prematurely. When the Stop tool is used (ie. Translation ABORTED), FME kills the process immediately. The translation does not get the chance to complete and so the shutdown script does not run.

If the translation ends due to an error (ie. Translation FAILED due to rejected feature or Terminator), the shutdown script runs as the translation does complete--cleanup is done, readers and writers are shut down, and log file is closed.

I hope this information helps.

Thanks Debbie,

 

Yeah after reading the documentation It is indeed expected behavior, but would be nice to have the option to run it anyway.

 

 

Cheers Debbie!

Reply