Danie1 / threads-api

Unofficial Python API for Meta's Threads App
https://pypi.org/project/threads-api/
MIT License
126 stars 16 forks source link

ERROR:Unclosed client session #44

Closed Abdurrafey-Siddiqui closed 1 year ago

Abdurrafey-Siddiqui commented 1 year ago

It posts the thread but I think there is an issue in creating the session to avoid future logins.

Post has been successfully posted ERROR:Unclosed client session client_session: <aiohttp.client.ClientSession object at 0x0000014F7491D130> ERROR:Unclosed connector connections: ['[(<aiohttp.client_proto.ResponseHandler object at 0x0000014F749E2160>, 245380.64)]'] connector: <aiohttp.connector.TCPConnector object at 0x0000014F7491D190>

My code:


from threads_api.src.http_sessions.aiohttp_session import AioHTTPSession
import asyncio
import os
from dotenv import load_dotenv

load_dotenv()

async def post():
    threads_api = ThreadsAPI()
    await threads_api.login('username', 'password')
    result = await threads_api.post("I am posting this from the threads api!")

    if result:
        print("Post has been successfully posted")
    else:
        print("Unable to post.")

async def main():
    await post()

# Create an event loop and run the main function
loop = asyncio.get_event_loop()
loop.run_until_complete(main())```
Abdurrafey-Siddiqui commented 1 year ago

Using the default AioHTTPSession. Also note that I manually added the httpsession folder and files since pip install upgrade did not add the files

Danie1 commented 1 year ago

Hi, thanks for reporting both issues.

I dedicated https://github.com/Danie1/threads-api/releases/tag/v1.1.11 for you @Abdurrafey-Siddiqui 🚀

Abdurrafey-Siddiqui commented 1 year ago

Thanks @Danie1. Also wanted to know is the script mean to create some sort of file with login cache? Because I didn't see anything pop up. Also great communication.

Danie1 commented 1 year ago

Thanks. Yes, once you specify the cached_token_path in the login() function the file in the path will be created after a successful login process. It will include your BEARER TOKEN encrypted.