-
Notifications
You must be signed in to change notification settings - Fork 72
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SSO token refresh failure - Cannot reuse already awaited coroutine #323
Comments
Ok this is an I take it, first time you ran the script just after an |
Hi, @terrycain! The strange thing is that with boto3 we did not get this exception. We ran the script for 3h and it succeeded with automatic token refresh. Then we decided to migrate to aioboto3, to improve the performance, as it was taking too much time for the script to finish. After the migration to aioboto3, we started to get this exception when the script was executing for about 1h and 30mins. And yes, at the start we use the |
Yeah so the problem is aioboto3 is built on top of aiobotocore which does the asyncification of the core parts of boto. There's a fair bit of complexity around the credential handling. So if im reading this correctly, the script takes 3+ hours, but half way through that, the sso tokens would have expired and need to be automatically renewed (which makes sense from the error). I'll look into seeing if I can replicate it. Oh and for reference if the script is like the one above, you'll not get any benefit from using aioboto3 as you're still doing operations in a synchronous fashion, you'll want to do stuff like |
Hi, @terrycain! For the example script, I wrote as little code as possible. In the real scenario, the script processes the returned object information with with async def process_element(element):
# S3 object processing
async def process_elements(elements):
routines = []
for element in elements:
routines.append(process_element(element))
await asyncio.gather(*routines) In the end, the issue is still open, and as a workaround, if any of the aioboto3 methods throw exception with the following context |
I created a script calling "sts.get_caller_identity()" in a loop. With the latest I think at this point, this isn't a bug and is expected behaviour. The error is similar to yours but I get a proper SSO Expired exception not reusing an awaited coro, which might potentially be your use of the libraries. Unless you have a script using the latest aioboto3 I can try and reproduce, I think theres nothing more for me to do here |
Description
I have developed a script that lists all objects from an S3 bucket. Then for every object, the script reads the object's metadata and appends the object information to a JSON file. Credentials for AWS are configured as SSO credentials. Before running the script the AWS credential session needs to be initialized and the profile name provided as a run argument to the script.
After executing the script, in about 1 hour and 30 mins, it fails due to a refresh token exception. Where one of the methods has been already awaited.
What I Did
The script is implemented with a similar code as below:
To run the script the following command is executed to start the SSO session
aws sso login --profile {PROFILE_NAME}
Then the script is executed with
py script.py --profile {PROFILE_NAME}
After about 1 hour and 30 minutes the following exception is thrown
The text was updated successfully, but these errors were encountered: