Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

If not running in main thread, create & set a new event loop. #7

Open
wants to merge 13 commits into
base: master
Choose a base branch
from

Conversation

ingo-m
Copy link

@ingo-m ingo-m commented Aug 31, 2020

When running TikTokAPI-Python in a subthread, I encountered an error:

RuntimeError: There is no current event loop in thread 'ThreadPoolExecutor-0_0'.

This RuntimeError does not occur when I use TikTokAPI-Python directly in a script (i.e. in the main python thread), but it does occur when calling TikTokAPI-Python from another (multithreaded) application. As far as I can see, if not running in the main thread, it's necessary to create & set a new event loop.

My proposed solution should not alter anything if running in the main thread, but avoid trouble otherwise.

@balmacefa
Copy link

balmacefa commented Jan 9, 2022

You can also use https://github.com/erdewit/nest_asyncio

import nest_asyncio
nest_asyncio.apply()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants