Skip to content
This repository has been archived by the owner on May 8, 2020. It is now read-only.

High CPU Usage while waiting for connect #275

Open
lorien opened this issue Dec 3, 2019 · 0 comments
Open

High CPU Usage while waiting for connect #275

lorien opened this issue Dec 3, 2019 · 0 comments

Comments

@lorien
Copy link

lorien commented Dec 3, 2019

Code:

import asyncio

import pyppeteer


async def main():
    try:
        await asyncio.wait_for(
            pyppeteer.connect(browserWSEndpoint='ws://localhost:3333'),
            timeout=3
        )
    except asyncio.TimeoutError:
        print('Timeout!')


if __name__ == '__main__':
    asyncio.get_event_loop().run_until_complete(main())

Endpoint is broken, port is closed, just random number.
If I run python code I'll see 100% CPU usage in top output.
If I run it with command sudo perf stat -e 'syscalls:*epoll_wait*' python3 test_wait.py
I'll get

 Performance counter stats for 'python3 test_wait.py':

           114,265      syscalls:sys_enter_epoll_wait                                   
           114,265      syscalls:sys_exit_epoll_wait 

So, in 3 seconds it made 100k+ epoll_wait() calls.

I am not expert in asyncio, puppeteer, C programming, syscals, etc. But I think it is not OK :) What do you think?

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

No branches or pull requests

1 participant