0

I need to start the download process in the background and I use something like this:

from threading import Thread

api = TikTokApi()


def foo():
    url = 'https://www.tiktok.com/@karna.val/video/6912082657761381633?sender_device=mobile&sender_web_id=6919748545793050118&is_from_webapp=1'
    file = api.get_Video_By_Url(video_url=url)
    print(file)


t = Thread(target=foo)
t.start()

But I get the error: greenlet.error: cannot switch to a different thread

How can i fix it?

1 Answers1

1

Add these lines in your code. This removes greenlet error

from gevent import monkey
monkey.patch_all()
srinivast6
  • 309
  • 3
  • 8