Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
# the results can be a single value (dict), or an array, or None,
# or an exception, or a tuple (type, exception, traceback)
hits = []
complete = True
if isinstance(results, list):
for result in results:
if result:
if isinstance(result, (tuple, ThreatLookupIncompleteException)):
LOG.info("Retry later!")
complete = False
elif isinstance(result, (tuple, Exception)):
LOG.error("No hits due to exception")
else:
hits.append(result)
elif results:
if isinstance(results, (tuple, ThreatLookupIncompleteException)):
LOG.info("Retry later!")
complete = False
elif isinstance(results, (tuple, Exception)):
LOG.error("No hits due to exception")
else:
hits.append(results)
# Store the result and mark as complete (or not)
cache_key = (cts_channel, request_id)
self.cache[cache_key] = {"id": request_id, "artifact": artifact, "hits": hits, "complete": complete}