Comments (7)
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.
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.
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.
@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.
I can confirm I'm experiencing this behavior on OS X (10.12.6) and Python 3.6.5
from pyppeteer.
I experience the same on Arch Linux, Python 3.8.1.
from pyppeteer.
Same Ubuntu 19.10, python 3.7
from pyppeteer.
Related Issues (20)
- how to clear the input area?
- Page.cookies() returns List, not Dict HOT 1
- TypeError: 'coroutine' object is not callable, why? HOT 1
- Support ARM OS HOT 1
- Navigation Timeout Exceeded: 30000 ms exceeded HOT 7
- Error browser closes unexpectedly HOT 1
- Can I get innerHTML from the Element Handle Class? HOT 1
- Response.buffer() return str rather than [bytes] HOT 1
- Pyppeteer on python 3.6.8 HOT 1
- UTF-8 characters are coming as garbage HOT 1
- KeyError when send HOT 1
- SyntaxError: invalid escape sequence HOT 2
- Is pyppeteer still maintained? HOT 4
- --enable-automation HOT 1
- can we use the cookies in python request from puppeteer cookies? HOT 1
- Page goto returns None HOT 2
- Execution context was destroyed, most likely because of a navigation. HOT 2
- Is there a forum or something for specific question related to pyppeteer? HOT 1
- Screenshot is not working in headless HOT 1
- >> REPOSITORY ABANDONED >> use pyppeteer2 instead HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pyppeteer.