How to use the polling2.poll function in polling2

To help you get started, we’ve selected a few polling2 examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github rapid7 / insightconnect-plugins / ivanti_security_controls / icon_ivanti_security_controls / actions / start_patch_scan / action.py View on Github external
"diagnosticTraceEnabled": params.get(Input.DIAGNOSTIC_TRACE_ENABLED),
            "endpointNames": endpoint_names,
            "machinegroupIds": machine_group_ids,
            "name": params.get(Input.NAME),
            "runAsCredentialId": params.get(Input.RUN_AS_CREDENTIAL_ID),
            "templateId": params.get(Input.TEMPLATE_ID),
            "useMachineCredential": use_machine_credential
        }
        
        self.connection.ivanti_api.create_session_credential()

        scan = self.connection.ivanti_api.start_patch_scan(payload)

        try:
            operation_location_url = scan.headers.get("Operation-Location")
            polling2.poll(lambda: self.connection.ivanti_api.get_operation_location(operation_location_url)
            .get("percentComplete") == 100, step=10, timeout=max_poll_time)
        except KeyError as e:
            raise PluginException(
                cause=f'{e} not found within the header.',
                assistance=f'If the issue persists please contact support.')
        except polling2.TimeoutException as e:
            raise PluginException(
                cause='Action timeout.',
                assistance=f'This scan has exceeded the maximum poll time of {max_poll_time}.')

        operation_location = self.connection.ivanti_api.get_operation_location(operation_location_url)
        scan_details = scan.json()
        scan_details['isComplete'] = True
        scan_details['updatedOn'] = operation_location['lastAction']

        return {

polling2

Updated polling utility with many configurable options

MIT
Latest version published 3 years ago

Package Health Score

58 / 100
Full package analysis

Popular polling2 functions