Skip to main content

The following lines of code work when run as an independent python script, ie python script.py.  These lines also work when run in the startup portion of the script.  The exact same lines however do not run when run in a shutdown script.  When run in a shutdown script the fme.exe process crashes and I get the following error in fme log:

Precondition failed at stfconf.cpp:798. Expression: instance_ != 0

The lines of code I am trying to run read a static .ffs file. They are:

ffsFile = r'<path to any .ffs file you have>'
import fmeobjects

# The following line never completes.
reader = fmeobjects.FMEUniversalReader('FFS', False, Â])
reader.open(ffsFile,  ])
feature = reader.read()
featureCnt = 0
while feature != None:
    featureCnt += 1
    feature = reader.read()
print 'featureCnt:', featureCnt
reader.close()

I am trying to do some automated reporting of failed features after the script has completed by reporting on the number of features that did not pass, and possibly more information down the road.  In order to do that i NEED the code above to work in the shutdown process.

Any suggestions welcome.  Please and thanks!

Thanks for reporting this issue. We've started tracking this internally as PR82862.


Hi @guy_lafleur

I'm sorry you ran into this issue. In the documentation for Startup and Shutdown Python Scripts, it mentions that calls to the FME Objects API made within a Shutdown script may be unpredictable as resources required are no longer available.

As a workaround, would you be able to use a FeatureWriter and connect a PythonCaller in place of a shutdown Python script?


Hi @guy_lafleur

I'm sorry you ran into this issue. In the documentation for Startup and Shutdown Python Scripts, it mentions that calls to the FME Objects API made within a Shutdown script may be unpredictable as resources required are no longer available.

As a workaround, would you be able to use a FeatureWriter and connect a PythonCaller in place of a shutdown Python script?

Hey Debbi

 

 

Thanks for getting back to me. We have created a framework that has method stub calls in the startup and shutdown of the many (400 +) replication scripts to allow us to inject in new logic to help make our replications more robust as well as have better reporting when they fail or do unexpected things. We are aware that many of replications are silently dropping features that they are unable to copy from source to destination for whatever reason. Our idea was to inject in logic that did a feature count in shutdown of features in the ffs file associated with the job.

 

 

Its disappointing that fme objects is not available in shutdown. It seems odd that this would be the case. Maybe what we want to do is just not possible. While I'm sure your proposed solution would work, its not really feasable for us as it would require manually editing all or our fmw's. Any other ideas? I'm thinking I might try calling the script as a separate subprocess, and passing the results back via stdout. Its a pretty ugly/cludgy solution. Hoping you guys have another suggestion???

 

 

Thanks very much for you help

 

 

Kevin

 


Hmm, I'm out of time for the week, but thinking this might also work:

https://stackoverflow.com/questions/14015405/reloading-module-which-has-been-imported-to-another-module

Will try next week.


Reply