talkiq / gcloud-aio

(Asyncio OR Threadsafe) Google Cloud Client Library for Python
https://talkiq.github.io/gcloud-aio
276 stars 91 forks source link

AttributeError #346

Closed umax closed 3 years ago

umax commented 3 years ago

Hi!

I got error while creating new task. Code example:

async def create_task(payload):
    client = PushQueue(
        project=settings.GCLOUD_PROJECT_ID,
        taskqueue=settings.GCLOUD_SYNC_CLOSEIO_QUEUE_NAME,
        service_file=os.environ['GOOGLE_APPLICATION_CREDENTIALS'],
        location=settings.GCLOUD_QUEUE_REGION,
    )
    task = {
        'httpRequest': {
            'httpMethod': 'POST',
            'url': settings.SERVICE_URL + '/restaurants/%s/closeio/' % payload['restaurant_id'],
            'headers': {
                'X-Service-Id': settings.X_SERVICE_ID,
                'X-Auth-Token': settings.AUTH_TOKEN,
            },
            'body': json.dumps(payload),
        }
    }

    await client.create(task)
    await client.close()

Stacktrace:

line 166, in request resp = await self.session.request(method, url, headers=headers, File "/usr/local/lib/python3.9/site-packages/aiohttp/client.py", line 428, in _request tm = TimeoutHandle(self._loop, real_timeout.total) AttributeError: 'int' object has no attribute 'total'
TheKevJames commented 3 years ago

Hmm, interesting, looks like aiohttp is erroring here: it's getting an integer timeout value instead of a aiohttp.Timeout helper. They deprecated passing in the integer a ways back, but last I saw they weren't planning on nuking support until v4 (which this library does not yet support).

Which version of aiohttp do you have installed?

TheKevJames commented 3 years ago

Oh, hold up, I see the PushQueue code is using some legacy code which has an issue in the fallback handling. I'll get a PR up -- thanks for the report!

umax commented 3 years ago

hi, @TheKevJames! I use gcloud-aio-datastore==6.2.2 and gcloud-aio-taskqueue==4.2.0 and it installs aiohttp==3.7.4.post0

umax commented 3 years ago

Hi, team!

Any updates?

TheKevJames commented 3 years ago

@umax I've just finalized a PR for fixing this: #347. As soon as we can review it, we'll get it released!

umax commented 3 years ago

Thank you, @TheKevJames !

TheKevJames commented 3 years ago

@umax the above bugfix is now live in gcloud-aio-taskqueue v4.2.1. Thanks again for the bug report!

umax commented 3 years ago

Thank you!