Skip to content
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

AWS_PROFILE: TypeError: can't pickle coroutine objects #663

Closed
spg opened this issue Jan 17, 2019 · 5 comments
Closed

AWS_PROFILE: TypeError: can't pickle coroutine objects #663

spg opened this issue Jan 17, 2019 · 5 comments

Comments

@spg
Copy link

spg commented Jan 17, 2019

Hey! I get the following error:

(instance-service366) ~/instance-service - [master●●] » python test_aiobotocore.py
Enter MFA code for arn:aws:iam::[redacted]:mfa/spgingras:
Traceback (most recent call last):
  File "test_aiobotocore.py", line 12, in <module>
    loop.run_until_complete(go(loop))
  File "/Users/spgingras/.pyenv/versions/3.6.6/lib/python3.6/asyncio/base_events.py", line 468, in run_until_complete
    return future.result()
  File "test_aiobotocore.py", line 8, in go
    resp = await client.list_buckets()
  File "/Users/spgingras/.virtualenvs/instance-service366/lib/python3.6/site-packages/aiobotocore/client.py", line 92, in _make_api_call
    operation_model, request_dict)
  File "/Users/spgingras/.virtualenvs/instance-service366/lib/python3.6/site-packages/aiobotocore/endpoint.py", line 226, in _send_request
    request = self.create_request(request_dict, operation_model)
  File "/Users/spgingras/.virtualenvs/instance-service366/lib/python3.6/site-packages/botocore/endpoint.py", line 116, in create_request
    operation_name=operation_model.name)
  File "/Users/spgingras/.virtualenvs/instance-service366/lib/python3.6/site-packages/botocore/hooks.py", line 356, in emit
    return self._emitter.emit(aliased_event_name, **kwargs)
  File "/Users/spgingras/.virtualenvs/instance-service366/lib/python3.6/site-packages/botocore/hooks.py", line 228, in emit
    return self._emit(event_name, kwargs)
  File "/Users/spgingras/.virtualenvs/instance-service366/lib/python3.6/site-packages/botocore/hooks.py", line 211, in _emit
    response = handler(**kwargs)
  File "/Users/spgingras/.virtualenvs/instance-service366/lib/python3.6/site-packages/botocore/signers.py", line 90, in handler
    return self.sign(operation_name, request)
  File "/Users/spgingras/.virtualenvs/instance-service366/lib/python3.6/site-packages/botocore/signers.py", line 149, in sign
    auth = self.get_auth_instance(**kwargs)
  File "/Users/spgingras/.virtualenvs/instance-service366/lib/python3.6/site-packages/botocore/signers.py", line 229, in get_auth_instance
    frozen_credentials = self._credentials.get_frozen_credentials()
  File "/Users/spgingras/.virtualenvs/instance-service366/lib/python3.6/site-packages/botocore/credentials.py", line 518, in get_frozen_credentials
    self._refresh()
  File "/Users/spgingras/.virtualenvs/instance-service366/lib/python3.6/site-packages/botocore/credentials.py", line 413, in _refresh
    self._protected_refresh(is_mandatory=is_mandatory_refresh)
  File "/Users/spgingras/.virtualenvs/instance-service366/lib/python3.6/site-packages/botocore/credentials.py", line 429, in _protected_refresh
    metadata = self._refresh_using()
  File "/Users/spgingras/.virtualenvs/instance-service366/lib/python3.6/site-packages/botocore/credentials.py", line 177, in __call__
    return self._refresh()
  File "/Users/spgingras/.virtualenvs/instance-service366/lib/python3.6/site-packages/botocore/credentials.py", line 566, in fetch_credentials
    return self._get_cached_credentials()
  File "/Users/spgingras/.virtualenvs/instance-service366/lib/python3.6/site-packages/botocore/credentials.py", line 577, in _get_cached_credentials
    self._write_to_cache(response)
  File "/Users/spgingras/.virtualenvs/instance-service366/lib/python3.6/site-packages/botocore/credentials.py", line 602, in _write_to_cache
    self._cache[self._cache_key] = deepcopy(response)
  File "/Users/spgingras/.virtualenvs/instance-service366/lib/python3.6/copy.py", line 169, in deepcopy
    rv = reductor(4)
TypeError: can't pickle coroutine objects
sys:1: RuntimeWarning: coroutine 'AioBaseClient._make_api_call' was never awaited
Unclosed client session
client_session: <aiohttp.client.ClientSession object at 0x107a81518>

When setting the AWS_PROFILE environment variable, and running the following script:

import asyncio
import aiobotocore


async def go(loop):
    session = aiobotocore.get_session(loop=loop)
    async with session.create_client('s3') as client:
        resp = await client.list_buckets()
        print(resp)

loop = asyncio.get_event_loop()
loop.run_until_complete(go(loop))

Probably related to #619 but not sure.

Running on python 3.6.6 in OS X Mojave.
Using a fresh virtualenv, with only aiobotocore==0.10.0 installed.

@thehesiod
Copy link
Collaborator

Does this happen with 0.9.4?

@thehesiod
Copy link
Collaborator

I just tried, could not reproduce:

(aiobotocore) amohr@amohr-macbook ~/dev/third_party/aiobotocore (master) $ pip freeze
-e git+https://github.com/aio-libs/aiobotocore.git@b0805f880d901966be11ae135a1f67f27aa2b7ef#egg=aiobotocore
aiohttp==3.5.4
async-timeout==3.0.1
attrs==18.2.0
botocore==1.12.49
chardet==3.0.4
docutils==0.14
idna==2.8
idna-ssl==1.1.0
jmespath==0.9.3
multidict==4.5.2
python-dateutil==2.7.5
six==1.12.0
typing-extensions==3.7.2
urllib3==1.24.1
wrapt==1.11.1
yarl==1.3.0

@thehesiod
Copy link
Collaborator

thehesiod commented Mar 1, 2019

looks like this is assume role, we've repro'd this locally

@thehesiod
Copy link
Collaborator

try this monkeypatch:

_orig_create_client = botocore.credentials.AssumeRoleCredentialFetcher._create_client


def _create_client(self):
    frozen_credentials = self._source_credentials.get_frozen_credentials()
    if not getattr(self, '_boto_session', None):
        self._boto_session = botocore.session.Session()

    return self._boto_session.create_client(
        'sts',
        aws_access_key_id=frozen_credentials.access_key,
        aws_secret_access_key=frozen_credentials.secret_key,
        aws_session_token=frozen_credentials.token,
    )

botocore.credentials.AssumeRoleCredentialFetcher._create_client = _create_client

@thehesiod
Copy link
Collaborator

unfortunately this is a dup of #619, closing this in favor of other. Please track that other issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants