fmeobjects.FMEUniversalReader.setCachingCallback

FMEUniversalReader.setCachingCallback(function, frequency)

This method provides FME with a callback function that will be called while caching features from a dataset.

Caching of an uncached dataset will occur when setConstraints() is used for reading a dataset or when a reader is set to cache on schema read.

In the setConstraints() case, caching will start when the first feature is read.

In the schema read case, caching will start when the first schema feature is read. A reader is set to cache on schema read by passing in the kFME_ReadCachedSchema key/value pair in the creation directives for the FMEUniversalReader.

The callback method should return a bool, where True means to continue caching and False means to stop. Stopping does not invalidate the cache. It will still be functional, but only up to the number of features cached. The method should also accept an int parameter that will specify the number of features that have been cached up to that point. e.g. callbackFunction(numFeaturesCached)

The rate FME calls the callback function will be determined by the frequency parameter, which is the number of features cached per call to the callback. In some cases, FME may cache more than the frequency parameter in a single cache operation. In those cases, the callback will be called as close to the frequency as possible.

Specifying a callback function of None will turn off the callback.

Exceptions raised by the callback method will mean the equivalent of a False return value.

Parameters:
  • function (Callable) – The function to provide FME for use as a callback function.

  • frequency (int) – The frequency of calling the callback method based on the number of features cached.

Return type:

None