I'm using the Box API (https://developer.box.com/guides/tooling/sdks/python/). I can get an access token, though it expires after a certain amount of time. My plan is to store the access token on the filesystem and use it until it expires, then fetch a new one. In the example below assume I have an expired access token.
# This next line does not throw an error: client.folder('0').get_items() # But iteration does (maybe this is a lazy fetch?) for _ in client.folder('0').get_items(): logger.debug("Using existing access token.") return access_token # So I use try/except try: for _ in client.folder('0').get_items(): logger.debug("Using existing access token.") return access_token except boxsdk.exception.BoxAPIException: pass # access token invalid, let's get one else: pass # access token invalid, let's get one # When running the debugger the except clause seems to catch the first throw, but the loop I think continues, throws the error again, and that second throw is not caught. -- https://mail.python.org/mailman/listinfo/python-list