Giter VIP home page Giter VIP logo

Comments (7)

scythargon avatar scythargon commented on May 10, 2024 3

Same here. I just terminate them manually now.

import signal, psutil, os


def kill_child_processes(parent_pid, sig=signal.SIGTERM):
    try:
        parent = psutil.Process(parent_pid)
    except psutil.NoSuchProcess:
        return
    children = parent.children(recursive=True)
    print(children)
    for process in children:
        process.send_signal(sig)


kill_child_processes(os.getpid())

from pyppeteer.

sjoerd222888 avatar sjoerd222888 commented on May 10, 2024 3

Not correctly terminating is a "downer" for using the library at a larger scale. Having to manually kill chrome processes that are not correctly terminated is not nice. A proper mechanism should go beyond using something like await asyncio.sleep(5) and hope in the mean-time the process terminated. This 5 seconds might work on a machine that is not under heavy load.

There should be something deterministic and await browser.close() should just clean up everything with no timeout required. Otherwise this library is not usable on larger scale where you execute many operations simultaneously and therefore the PC is under heavy load already. For some reason I saw cases where also termination from python as suggested by @scythargon did not do the job. I have no idea why.

Btw. for the rest this library works fine with multiprocessing, only this "process leaks" are a bit painful and require monitoring and manual intervention.

from pyppeteer.

miyakogi avatar miyakogi commented on May 10, 2024

Not reproduced on my environment (linux) with the below code:

import asyncio
from pyppeteer import launch

async def main():
    browser = await launch(headless=False)
    await asyncio.sleep(5)
    await browser.close()   # browser closes here
    await asyncio.sleep(5)

asyncio.get_event_loop().run_until_complete(main())

Could you let me know your OS and the version of pyppeteer?
Latest pyppeteer version is 0.0.17, and its browser.close() method does not call self.disconnect().

from pyppeteer.

scythargon avatar scythargon commented on May 10, 2024

@csugzq
Hey, can you try this please - resp.html.session.browser.close().
I investigated it here - https://github.com/kennethreitz/requests-html/issues/165

from pyppeteer.

rjjanuary avatar rjjanuary commented on May 10, 2024

I can confirm I'm experiencing this behavior on OS X (10.12.6) and Python 3.6.5

from pyppeteer.

sjoerd222888 avatar sjoerd222888 commented on May 10, 2024

I experience the same on Arch Linux, Python 3.8.1.

from pyppeteer.

vbxx3 avatar vbxx3 commented on May 10, 2024

Same Ubuntu 19.10, python 3.7

from pyppeteer.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.