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

minify_html block with minify_js or minify_css option #116

Closed
huoyingyangjie opened this issue Oct 25, 2022 · 11 comments
Closed

minify_html block with minify_js or minify_css option #116

huoyingyangjie opened this issue Oct 25, 2022 · 11 comments

Comments

@huoyingyangjie
Copy link

huoyingyangjie commented Oct 25, 2022

#0  pthread_cond_wait@@GLIBC_2.3.2 () at ../nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S:185
#1  0x00007ffa39700a3c in ?? () from /root/.pyenv/versions/3.7.2/lib/python3.7/site-packages/minify_html.cpython-37m-x86_64-linux-gnu.so
#2  0x00007ffa396fa209 in ?? () from /root/.pyenv/versions/3.7.2/lib/python3.7/site-packages/minify_html.cpython-37m-x86_64-linux-gnu.so
#3  0x00007ffa396fa2c2 in ?? () from /root/.pyenv/versions/3.7.2/lib/python3.7/site-packages/minify_html.cpython-37m-x86_64-linux-gnu.so
#4  0x00007ffa396e5fc5 in ?? () from /root/.pyenv/versions/3.7.2/lib/python3.7/site-packages/minify_html.cpython-37m-x86_64-linux-gnu.so
#5  0x00007ffa396e7947 in ?? () from /root/.pyenv/versions/3.7.2/lib/python3.7/site-packages/minify_html.cpython-37m-x86_64-linux-gnu.so
#6  0x00007ffa396e5c76 in ?? () from /root/.pyenv/versions/3.7.2/lib/python3.7/site-packages/minify_html.cpython-37m-x86_64-linux-gnu.so
#7  0x00007ffa396e7947 in ?? () from /root/.pyenv/versions/3.7.2/lib/python3.7/site-packages/minify_html.cpython-37m-x86_64-linux-gnu.so
#8  0x00007ffa396e5c76 in ?? () from /root/.pyenv/versions/3.7.2/lib/python3.7/site-packages/minify_html.cpython-37m-x86_64-linux-gnu.so
#9  0x00007ffa396e7947 in ?? () from /root/.pyenv/versions/3.7.2/lib/python3.7/site-packages/minify_html.cpython-37m-x86_64-linux-gnu.so
#10 0x00007ffa396e5c76 in ?? () from /root/.pyenv/versions/3.7.2/lib/python3.7/site-packages/minify_html.cpython-37m-x86_64-linux-gnu.so
#11 0x00007ffa396aec60 in ?? () from /root/.pyenv/versions/3.7.2/lib/python3.7/site-packages/minify_html.cpython-37m-x86_64-linux-gnu.so
#12 0x00007ffa396a5d1b in ?? () from /root/.pyenv/versions/3.7.2/lib/python3.7/site-packages/minify_html.cpython-37m-x86_64-linux-gnu.so
#13 0x00007ffa396a80d0 in ?? () from /root/.pyenv/versions/3.7.2/lib/python3.7/site-packages/minify_html.cpython-37m-x86_64-linux-gnu.so
#14 0x00007ffa396a5f09 in ?? () from /root/.pyenv/versions/3.7.2/lib/python3.7/site-packages/minify_html.cpython-37m-x86_64-linux-gnu.so
@huoyingyangjie huoyingyangjie changed the title minify_html block with minify_js or minify_css minify_html block with minify_js or minify_css option Oct 25, 2022
@wilsonzlin
Copy link
Owner

If I understand correctly, the thread is getting blocked by some function? Can you provide a small reproducible example code that will trigger this condition? Also, which version of the library are you using?

@huoyingyangjie
Copy link
Author

  • minify-html version: 0.6.10
  • program language: python3.7.2
  • usage:
minify_html.minify(data, minify_js=True, minify_css=True)

Note: when use it Individually, it's ok. However, it blocked when use it with gunicorn. Will it go wrong in a multi process or thread environment?

@wilsonzlin
Copy link
Owner

Sorry, I meant a sample HTML input i.e. the value of the data argument. Both JS and CSS minifiers don't have any fancy execution model, so they will block the thread. There's nothing that can be made async within this library anyway, since it's all computation, no I/O. I'd suggest using a thread pool and queues if you plan on using this on a single-threaded web server for every request, although if it's just to minify responses I'd strongly suggest pre-minifying the templates instead of doing it on the fly.

@wilsonzlin
Copy link
Owner

wilsonzlin commented Oct 26, 2022

Also I noticed that you are using an old version, and there were some issues with how the esbuild integration interacts with the host process. The CSS and JS minifiers have since been replaced with fully Rust-based ones, so try using the latest version.

@huoyingyangjie
Copy link
Author

Failed to compile:

cd minify-html/python/main
cargo build --release
error[E0432]: unresolved imports `minify_html::minify`, `minify_html::Cfg`
 --> src/lib.rs:1:19
error[E0659]: `minify_html` is ambiguous
  --> src/lib.rs:1:5

@wilsonzlin
Copy link
Owner

You can simply install using pip install minify-html, prebuilt libraries are available.

To build from source, you'll need to have Node.js and Rust installed. Run these commands from the repo directory:

bash ./prebuild.sh
pushd python/main
cargo build --release

@huoyingyangjie
Copy link
Author

pip install minify-html only support 0.6.10
As your above cmds, i still got same errors.

@wilsonzlin
Copy link
Owner

Ah yes, this is because of the PR #112 merged a few hours ago, I've pushed a fix, pull it and let me know if it works on your end.

@huoyingyangjie
Copy link
Author

As your proposal, compilation passed and block is not found.It's ok. On the other hand, failed to upgrade from 0.6.10 to 0.10.2.

command:

pip install  --upgrade minify_html==0.10.2

error info:

ERROR: Could not find a version that satisfies the requirement minify_html==0.10.2 (from versions: 0.2.6, 0.3.0, 0.3.1, 0.3.2, 0.3.3, 0.3.4, 0.3.5, 0.3.6, 0.3.7, 0.3.8, 0.3.9, 0.3.10, 0.3.11, 0.3.12, 0.4.0, 0.4.1, 0.4.2, 0.4.3, 0.4.5, 0.4.6, 0.4.7, 0.4.8, 0.4.9, 0.4.10, 0.4.11, 0.5.0, 0.5.2, 0.5.3, 0.6.0, 0.6.1, 0.6.2, 0.6.3, 0.6.4, 0.6.5, 0.6.7, 0.6.8, 0.6.9, 0.6.10)
ERROR: No matching distribution found for minify_html==0.10.2

@wilsonzlin
Copy link
Owner

That's great to hear that the problem has been resolved.

Python 3.7 isn't supported, it's mentioned in the README that the minimum version is 3.8.

@huoyingyangjie
Copy link
Author

Ok, it has no problem at python3.7 temporarily.

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

No branches or pull requests

2 participants