question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[BUG] - greenlet.error: cannot switch to a different thread

See original GitHub issue

I tried to combine into django with this TikTokApi, before that there was no problem when I was using version 3.7.5 it worked smoothly.

However, after I upgraded the version this error occurred

  File "/home/handoko/DEV/EVELLO/ven/lib/python3.8/site-packages/rest_framework/views.py", line 506, in dispatch
    response = handler(request, *args, **kwargs)
  File "/home/handoko/DEV/EVELLO/ven/lib/python3.8/site-packages/rest_framework/decorators.py", line 50, in handler
    return func(*args, **kwargs)
  File "/home/handoko/DEV/EVELLO/evello-scrapper/tiktok/views.py", line 113, in by_trending
    trending = api.trending(n_post)
  File "/home/handoko/DEV/EVELLO/ven/lib/python3.8/site-packages/TikTokApi/tiktok.py", line 256, in trending
    res = self.getData(url=api_url, **kwargs)
  File "/home/handoko/DEV/EVELLO/ven/lib/python3.8/site-packages/TikTokApi/tiktok.py", line 136, in getData
    verify_fp, did, signature = self.browser.sign_url(**kwargs)
  File "/home/handoko/DEV/EVELLO/ven/lib/python3.8/site-packages/TikTokApi/browser.py", line 162, in sign_url
    page = self.create_page()
  File "/home/handoko/DEV/EVELLO/ven/lib/python3.8/site-packages/TikTokApi/browser.py", line 110, in create_page
    context = self.browser.newContext(**iphone)
  File "/home/handoko/DEV/EVELLO/ven/lib/python3.8/site-packages/playwright/sync_api.py", line 6188, in newContext
    self._sync(
  File "/home/handoko/DEV/EVELLO/ven/lib/python3.8/site-packages/playwright/sync_base.py", line 105, in _sync
    dispatcher_fiber_.switch()
greenlet.error: cannot switch to a different thread

I tried to return to the previous version too, but it still got an error. hoping for an answer

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:2
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

3reactions
ranahaanicommented, Jan 24, 2021

@davidteather not fixed yet

0reactions
Auth0rM0rgancommented, Aug 16, 2021

not working for me as well. any solution?

Read more comments on GitHub >

github_iconTop Results From Across the Web

[BUG] greenlet.error: cannot switch to a different thread #1422
Exception ignored in thread started by: <function do_work at 0x0000017D638D3700> Traceback (most recent call last): File "D:\test\main.py", ...
Read more >
greenlet.error: cannot switch to a different thread
Something similar happened to me when I tried to debug a flask application using Pycharm. What I finally did to eventually solve my...
Read more >
greenlet.error not raised switching between threads for main ...
Consider this code snippet. It starts a background thread and exposes an attribute that allows switching to the main greenlet of the ...
Read more >
eventlet errors and cannot switch to a different thread
During the deletion of a volume eventlet can error being unable to switch threads. We also see that the volume fails to delete...
Read more >
Greenlets and Python Threads - Read the Docs
It is not possible to mix or switch between greenlets belonging to different threads.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found