Russell-Newton / TikTokPy

Extract data from TikTok without needing any login information or API keys.
https://pypi.org/project/tiktokapipy/
MIT License
203 stars 25 forks source link

Any luck deploying on AWS Lambda? #60

Open liechtym opened 1 year ago

liechtym commented 1 year ago

Love the library! Thanks for all your great work.

I'm wondering if anyone has used this library in AWS Lambda successfully? I have tried and it seems to have trouble because of Chromium.

Thanks in advance for any suggestions.

Russell-Newton commented 1 year ago

I'm not really familiar with AWS Lambda, but after a little bit of digging around, it looks like Chromium tries to spawn some additional processes, which Lambda really doesn't like. This is something you can disable in the launch args, which are passed through the API constructor.

It's worth trying to construct the api with the extra kwarg args=["--disable-gpu", "--single-process"], something like:

with TikTokAPI(args=["--disable-gpu", "--single-process"]) as api:
    ...

or

async with AsyncTikTokAPI(args=["--disable-gpu", "--single-process"]) as api:
    ...

depending on which version of the API you're using.