PaloAltoNetworks / pan-cortex-data-lake-python

Python idiomatic SDK for Cortex™ Data Lake.
https://cortex.pan.dev/docs/data_lake/develop/cdl_python_installation
ISC License
44 stars 18 forks source link

Enhancement: poll_all() and iter_poll() improved loop control #21

Closed btorresgil closed 6 years ago

btorresgil commented 6 years ago

Description

Currently the poll_all() and iter_poll() methods loop through all the pages of results until the last page is found. There are two suggestions for improvements to allow better control of this loop:

Suggestion 1:

Add a timeout= keyword argument with a sensible default. This would act as a timeout for the whole operation which allows a developer to restrict how long a poll job can run. This can be done currently with iter_poll() where the developer manages their own timeout, but we can make it easier by adding the argument.

Suggestion 2:

Currently, the loop uses else to assume the query status is RUNNING. This could result in an infinite loop if the API changes or fails. To better future-proof the library, check for RUNNING explicitly and use else to raise an exception such as Unexpected query status: {}.

sserrata commented 6 years ago

Suggestion 1 Update:

Decided to retire poll_all method due to the following weaknesses::

Expect poll_all to be removed in the next minor release.