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

RuntimeWarning: coroutine 'browser.start' was never awaited and nothing is printed on async [BUG] #115

Closed
elblogbruno opened this issue Jun 5, 2020 · 19 comments
Labels
installation_help Someone is having problems installing the api

Comments

@elblogbruno
Copy link

Describe the bug
I'm putting this api inside a discord bot using discord.py, thus I'm running the api inside an async function. I'm getting this error that makes the bot close.
RuntimeError: Event loop is closed
sys:1: RuntimeWarning: coroutine 'Launcher.killChrome' was never awaited

The buggy code

async def tiktok_interact(message,channel):

trending = api.trending(results)

for tiktok in trending:
    # Prints the text of the tiktok
    print(tiktok['desc'])
    await channel.send(tiktok['video']['cover'])

print(len(trending))

Expected behavior

await channel.send function makes the bot send whatever text or input I insert.

Screenshots
image

Additional context

I'm running it on a debian 9 VPS.

@elblogbruno elblogbruno added the bug Something isn't working label Jun 5, 2020
@issue-label-bot
Copy link

Issue-Label Bot is automatically applying the label bug to this issue, with a confidence of 0.93. Please mark this comment with 👍 or 👎 to give our bot feedback!

Links: app homepage, dashboard and code for this bot.

@elblogbruno elblogbruno changed the title [BUG] Async [BUG] Jun 5, 2020
@davidteather
Copy link
Owner

You need to update your TikTokApi package. TikTok made changes yesterday that broke the package. Update with the following command.

pip install TikTokApi --upgrade

@elblogbruno
Copy link
Author

image
I'm still having the same issue!

@davidteather davidteather added installation_help Someone is having problems installing the api and removed bug Something isn't working labels Jun 5, 2020
@davidteather
Copy link
Owner

I'll be releasing a patch later today that might help your issue.

@davidteather davidteather reopened this Jun 5, 2020
@davidteather davidteather changed the title Async [BUG] runtimeWarning: coroutine 'Launcher.killChrome' was never awaited Jun 5, 2020
@elblogbruno
Copy link
Author

Thank you!🤗

@elblogbruno
Copy link
Author

Now I simply don't have an answer back from the library and after a long time this pops up
image

@davidteather
Copy link
Owner

I'm not super great with asyncio and I haven't run into this issue so I'll leave this open hoping someone else finds a solution.

@Inzilkin
Copy link

Inzilkin commented Jun 6, 2020

Yes, i know the solution

  1. Rewrite all library to async
    // async def ..
  2. delete from start pyppeteer class asyncio loop
    image
  3. start browser like that:
    image
  4. You have work async library

@Inzilkin
Copy link

Inzilkin commented Jun 6, 2020

3.1. Use aiohttp or another async library.
Thanks for reading my solution :)

@Inzilkin
Copy link

Inzilkin commented Jun 7, 2020

@davidteather, please rewrite requests to aiohttp.

@elblogbruno
Copy link
Author

There's any update about this?
Thanks

@elblogbruno
Copy link
Author

Now is not printing anything.

@elblogbruno elblogbruno changed the title runtimeWarning: coroutine 'Launcher.killChrome' was never awaited RuntimeWarning: coroutine 'browser.start' was never awaited and nothing is printed on async [BUG] Jul 1, 2020
@elblogbruno
Copy link
Author

pyppeteer/pyppeteer#143 Based on this I added autoClose to false and now it does not print anything and the program closes.

@Rodrigo-ip
Copy link

I'm getting the same thing : RuntimeWarning: coroutine 'browser.start' was never awaited then gc.collect()

@crazygmr101
Copy link
Contributor

crazygmr101 commented Jul 26, 2020

I can confirm running this in a discord bot breaks things. In my case, it's https://github.com/davidteather/TikTok-Api/blob/master/TikTokApi/browser.py#L52-L57. Writing those to use the current event loop, and using run_in_executor should fix the issue and allow it to be used with async libraries

update on this - im working on what could be a potential fix

@elblogbruno
Copy link
Author

Awesome @crazygmr101 let us know!

@crazygmr101
Copy link
Contributor

I submitted #198 - I'm not sure if it fixes this issue, but I did run it in a discord bot with

@bot.command()
async def tiktok(ctx: commands.Context, link: str):
    video = api.getTikTokByUrl(link)["itemInfo"]["itemStruct"]["video"]
    print(video)

@davidteather
Copy link
Owner

Try to use my comment on #235 it should resolve your issue. It might throw a lot of errors when the bot is closed, but it'll work.

@elblogbruno
Copy link
Author

Ok thanks I will test asap!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
installation_help Someone is having problems installing the api
Projects
None yet
Development

No branches or pull requests

5 participants