|SAM pools and multi-threading ||
One way to reduce the amount of time it takes to retrieve results from the 1010data Insights Platform is to "warm" the SAM pool by having pool IDs logged in ahead of time.
An ID from a SAM pool that was warmed is already logged into the Insights Platform. The warmPool function logs in available SAM pool user IDs, which can speed the retrieval of results for users. To this end, you can also provide queries to run on the warmed IDs when they log in.
Example without queries or a log file path and with them:
py1010.warmPool(gateway, owner, password, group)
py1010.warmPool(gateway, owner, password, group, queries=None, logfile=None)
You can run warmPool without logging in.
After the query results are retrieved, the used IDs should be released back into the pool of available IDs. For more information, see Cleaning up a session. These released IDs are not re-warmed automatically. When they are used again, the ID will have to be logged in.
The example below uses warmPool to warm the SAM pool and BaseQuery to provide a query:
#!/usr/bin/env python import py1010 url = "https://www2.1010data.com/prod-latest/gw" owner = "USERNAME" group = "GROUP" password = "PASSWORD" queries = [ py1010.BaseQuery("pub.demo.weather.stations", ""), py1010.BaseQuery("pub.demo.weather.hourly90", '''<sel value="(id=3103)"/>''') ] warmed=py1010.warmPool(url, owner, password, group, queries=queries, logfile="FOOO.log"); print("Warmed: %d"%warmed)