Skip to content

AttributeError: 'ClientTransaction' object has no attribute 'key' #304

Description

@Lv5Electro

env: ubuntu22.04, python3.10, twikit==2.3.3

I get a error:

Traceback (most recent call last):
File "/root/NewCrypto/listeners/twitter_listener.py", line 70, in process_usernames
await login(twitter_client, account, accounts, account_index, twitter_client)
File "/root/NewCrypto/listeners/twitter_listener.py", line 164, in login
await client.login(
File "/usr/local/lib/python3.10/dist-packages/twikit/client/client.py", line 339, in login
guest_token = await self._get_guest_token()
File "/usr/local/lib/python3.10/dist-packages/twikit/client/client.py", line 277, in _get_guest_token
response, _ = await self.v11.guest_activate()
File "/usr/local/lib/python3.10/dist-packages/twikit/client/v11.py", line 61, in guest_activate
return await self.base.post(
File "/usr/local/lib/python3.10/dist-packages/twikit/client/client.py", line 215, in post
return await self.request('POST', url, **kwargs)
File "/usr/local/lib/python3.10/dist-packages/twikit/client/client.py", line 145, in request
tid = self.client_transaction.generate_transaction_id(method=method, path=urlparse(url).path)
File "/usr/local/lib/python3.10/dist-packages/twikit/x_client_transaction/transaction.py", line 145, in generate_transaction_id
key = key or self.key or self.get_key(response)
AttributeError: 'ClientTransaction' object has no attribute 'key'

Maybe this error is caused by a login failure or an account ban? I'm not sure.
I checked the code, and theoretically, self.key should be initialized in the init function.
I hope the author can take a look. Additionally, I can't easily reproduce this error—I only know that it occurs after I send requests in bulk.

Additional info:
1.I used an IP pool and multiple accounts, with each IP corresponding to one account.
2.In my login function, I set enable_ui_metrics=False. When it's True, sending too many requests causes the program to freeze. It seems to be an issue with Js2Py.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions