davidteather / TikTok-Api

The Unofficial TikTok API Wrapper In Python
https://davidteather.github.io/TikTok-Api
MIT License
4.88k stars 975 forks source link

fix: playwright timeout sessions with provide opt-out params #1196

Open arhen opened 1 month ago

arhen commented 1 month ago

So, this PR is to provide opt-out solution for issues; #1185 and #994

PROBLEMS

when I try to figure out what is happening, most of the time the sessions is not long enough to handle the navigation process. This issue appear due to some problems such as; lack of resources when run the script, too much sessions to handle (ex: run alot of script once in a time), and another process block the session to finish.

SOLUTION

By default, playwright timeout sessions is 3000ms == 30 seconds. For those problems above, this default timeouts is not enough. So with opt-out the timeout params via creating session , we can override default playwright timeout sessions before navigation started.

IMPLEMENTATION

This PR basically adding opt-out params when creating session. ex:

await api.create_sessions(ms_tokens=[ms_token], num_sessions=1, sleep_after=3, timeout=60000)

this will let playwirght session started with 60secs timeout instead of 30s by default.