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

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

Open
Lv5Electro opened this issue Feb 10, 2025 · 0 comments
Open

Comments

@Lv5Electro
Copy link

Lv5Electro commented Feb 10, 2025

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.

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

1 participant