moto: Moto server hangs with the latest version of werkzeug (v2.2.1)
Here is what I do:
mamba env create -n test-moto # this creates a clean environment.
conda activate test-moto
pip install moto # OR mamba install moto -c conda-forge
moto_server -p 5555
then in a different terminal I run
curl "http://localhost:5555/"
Expected behavior:
The curl should immediately return a result.
Actual behavior:
The moto_server hangs. The process is at 100% CPU usage so maybe it is busy waiting for something (just a guess).
If werkzeug is manually downgraded to v2.1.0 (pip install Werkzeug=2.1.0) or previous everything works as expected.
Here is my complete pip freeze:
-- edit by @bblommers - removed to clean the thread a bit
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 1
- Comments: 24 (4 by maintainers)
Commits related to this issue
- Temporary pin Werkzeug version because moto hangs with newer one. See https://github.com/spulec/moto/issues/5341 — committed to neondatabase/neon by LizardWizzard 2 years ago
- Temporary pin Werkzeug version because moto hangs with newer one. See https://github.com/spulec/moto/issues/5341 — committed to neondatabase/neon by LizardWizzard 2 years ago
- upgpkg: python-moto 4.0.3-1; disable broken server tests See: https://github.com/spulec/moto/issues/5341 git-svn-id: file:///srv/repos/svn-community/svn@1300704 9fca08f4-af9d-4005-b8df-a31f2cc04f65 — committed to archlinux/svntogit-community by deleted user 2 years ago
- upgpkg: python-moto 4.0.3-1; disable broken server tests See: https://github.com/spulec/moto/issues/5341 git-svn-id: file:///srv/repos/svn-community/svn@1300704 9fca08f4-af9d-4005-b8df-a31f2cc04f65 — committed to archlinux/svntogit-community by deleted user 2 years ago
- pin moto>=4.0.8.dev17 to fix werkzeug>=2.2.2 dependency (relates to https://github.com/spulec/moto/issues/5341) — committed to crim-ca/weaver by fmigneault 2 years ago
- Pin released `moto>=4.0.8` Relates to https://github.com/spulec/moto/issues/5341 — committed to crim-ca/weaver by fmigneault 2 years ago
The breakage of werkzeug was a combination of things - werkzeug introduced some bugs, and also exposed some bugs in Moto. The upcoming
werkzeug==2.2.2release should at least stop Moto from hanging, but will still throw 404’s for some calls to Moto.For now, Moto has pinned the werkzeug-dependency to < 2.2.x until we have time to resolve this completely.
As a debugging note: Some of Moto’s issues can be solved by setting the attribute
RegexConverter.part_isolating = False. This will also cause other services to fail, as we only want this attribute for specific services - so we need to find a way to make this service-specific.There’s no date planned @jakirkham, but somewhere this week. I’d like to wait until we get some positive feedback that the dev-version works as expected… (hint, hint) 🙂
@jakirkham Moto 4.0.8 has now been released.
Looks like that is a bug that was fixed recently. I was on an older version of PIP,
pip 20.0.2, and using that exact same setup, PIP always installed the latest version for me:Upgrading PIP to
22.3fixes this, i.e. it does installwerkzeug 2.1.2.Having said that: I think a longterm fix, where we can use Moto with any werkzeug-version, is almost ready, so I’m going to focus on that instead.
@bblommers Is it possible to consider pinning
werkzeugonly if the server is used (e.g.: viamoto[server]or similar)? I am only using thes3portion ofmoto, and as far as I know,werkzeugversion is not critical in this case, althoughmotoforces downgrade where other packages in my environment can use latestwerkzeug.Just to note there are a few projects now copying this workaround. Some show up as xref’s in PR ( https://github.com/spulec/moto/pull/5330 ).
Wonder if it makes sense to include this version constraint in
motopackages to help users avoid this. Also curious whether this comes down to an upgrade needed inmotoor ifwerkzeugbroke something and this should be surfaced as an issue with that project.Just confirmed this myself in my own CI pipeline. The critical change was between v2.1.2 (works) and v2.2.0 (hangs) of that package. Everything else in my environment was kept the same.