kiwi0fruit / pyppdf

Pyppeteer PDF. Print html sites and files to pdf via pyppeteer (uses patched pyppeteer that by default downloads updated Chromium revision via https with certifi).
MIT License
37 stars 6 forks source link

Spawns zombie processes #9

Open caffeinatedgaze opened 4 years ago

caffeinatedgaze commented 4 years ago

After running the following command inside Debian GNU/Linux 10 (buster) docker image, I see multiple defunct processes. Each consequent run gives birth to 4 more zombies.

pyppdf -a "{'args': ['--disable-gpu', '--no-sandbox'],'goto': {'waitUntil':'networkidle0', 'timeout':100000},'pdf':{'printBackground':True, 'landscape':True, 'scale':0.7}}" 'file:///tmp/temp-pdfreport-page.html'

image

Note: I stumble across this issue independently of whether I run this utility using Python interface or the CLI.

caffeinatedgaze commented 4 years ago

Now it seems that the pyppeteer library has a flaw itself. The following sequence results in one additional zombie process.

from pyppeteer import launch browser = await launch(args=['--disable-gpu', '--no-sandbox', '--single-process']) await browser.close()

caffeinatedgaze commented 4 years ago

Well, I checked it inside the host Ubuntu machine. Works just fine. No zombies are spawned

caffeinatedgaze commented 4 years ago

Okay, this is already here https://github.com/miyakogi/pyppeteer/issues/274

kiwi0fruit commented 4 years ago

Looks like a nasty bug in the (unmaintained) pyppeteer. You can try using the same approach I use in knitty when dealing with buggy external deps: https://github.com/kiwi0fruit/knitty/blob/master/knitty/ast_filter.py

If you would try it please tell me if it worked.

caffeinatedgaze commented 4 years ago

Very nice, but will it be able to kill the orphaned processes? I've tried to kill those with Unix's kill and no success.

kiwi0fruit commented 4 years ago

Who knows... May be not. But we won't know until we try. And I don't know when I will have time to tinker with this...

kiwi0fruit commented 3 years ago

I implemented hack from https://github.com/kiwi0fruit/knitty/blob/master/knitty/ast_filter.py in the pyppdf 0.1.0. Latest version is 0.1.2.

But I have no idea if it fixes this bug as I don't want to hunt it and reproduce. But if you have the bug you can test 0.1.2 version and tell us if it worked.

kiwi0fruit commented 3 years ago

Ver. 0.1.1 might be slightly better. But anyway I have no idea what else to do. Latest version is 0.1.2.