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

Fix for Flask 2.2.0 breaking changes #2148

Merged

Conversation

mikenester
Copy link
Contributor

Fix for the following bug: #2147

The web.py change is obviously the fix, but without the changes to uitl.py, test_index_with_https has errors with python 3.7 & 3.8: https://github.com/mikenester/locust/runs/7642011804?check_suite_focus=true

Traceback (most recent call last):
  File "/home/runner/work/locust/locust/locust/test/test_web.py", line 463, in tearDown
    super().tearDown()
  File "/home/runner/work/locust/locust/locust/test/testcases.py", line 1[88](https://github.com/mikenester/locust/runs/7642011804?check_suite_focus=true#step:9:89), in tearDown
    clear_all_functools_lru_cache()
  File "/home/runner/work/locust/locust/locust/test/util.py", line 88, in clear_all_functools_lru_cache
    wrappers = [a for a in gc.get_objects() if isinstance(a, functools._lru_cache_wrapper)]
  File "/home/runner/work/locust/locust/locust/test/util.py", line 88, in <listcomp>
    wrappers = [a for a in gc.get_objects() if isinstance(a, functools._lru_cache_wrapper)]
ReferenceError: weakly-referenced object no longer exists

With this change, a ResourceWarning appears:

ResourceWarning: unclosed file <_io.TextIOWrapper name='web_test_stats.csv' mode='w' encoding='UTF-8'>
  gc.collect()
ResourceWarning: Enable tracemalloc to get the object allocation traceback
/home/runner/work/locust/locust/locust/test/util.py:[84](https://github.com/mikenester/locust/runs/7642594464?check_suite_focus=true#step:9:85): ResourceWarning: unclosed file <_io.TextIOWrapper name='web_test_stats_history.csv' mode='w' encoding='UTF-8'>
  gc.collect()
ResourceWarning: Enable tracemalloc to get the object allocation traceback
/home/runner/work/locust/locust/locust/test/util.py:84: ResourceWarning: unclosed file <_io.TextIOWrapper name='web_test_failures.csv' mode='w' encoding='UTF-8'>
  gc.collect()
ResourceWarning: Enable tracemalloc to get the object allocation traceback
/home/runner/work/locust/locust/locust/test/util.py:84: ResourceWarning: unclosed file <_io.TextIOWrapper name='web_test_exceptions.csv' mode='w' encoding='UTF-8'>
  gc.collect()
ResourceWarning: Enable tracemalloc to get the object allocation traceback

@cyberw
Copy link
Collaborator

cyberw commented Aug 3, 2022

Thanks! Just one question: what did cache_timeout=None do, and are we sure we dont need it anymore?

@cyberw
Copy link
Collaborator

cyberw commented Aug 3, 2022

I will add max_age=0 after merging, because it does the same thing that cache_timeout did

@cyberw cyberw merged commit 61f8b83 into locustio:master Aug 3, 2022
cyberw added a commit that referenced this pull request Aug 3, 2022
@mikenester
Copy link
Contributor Author

Thanks! Just one question: what did cache_timeout=None do, and are we sure we don't need it anymore?

I'm not totally sure, but send_file already defaulted it to None. So it wasn't being used, as far as I can tell

@mikenester mikenester deleted the request-stats-fix-for-flask-update branch August 3, 2022 14:47
danigoland added a commit to danigoland/locust that referenced this pull request Aug 9, 2022
* More robust handling of ZMQ/RPC errors (locustio#2120)

* More robust RPC error handling on msg from worker

* Use dedicated exceptions, fewer nested try blocks

* Fix test_zmqrpc.py

* Undo function split since added new exceptions

* Fix more tests

* Fix some tests

* Fix typo

* Fix scoping of variables

* Add tests for RPC/ZMQ changes

* flake and black fixes

* Remove debug print line

Co-authored-by: Ryan Warner <ryan.warner@edgecast.com>

* Remove timeout parameter from FastHttpUser unit tests

* Update changelog for 2.10

* Increase CONNECT_RETRY_COUNT to avoid workers giving up too soon if master is not up yet

* Escape user supplied data in html report (locustio#2126) (locustio#2127)

* Escape user supplied data in html report (locustio#2126)

authored-by: Tom Herrmann <t.herrmann@sab-engineering.com>

* Replace the MD5 usage by SHA256

MD5 is old, insecure, and can create problems for people using this package when they are trying to pass some compliance requirements (for example, FIPS).

* Fix escaping for exceptions in normal web ui (related to locustio#2126)

* implement table-sorting in report.html

* fix: Fix typo at user/wait_time.py

* improve report sorting

* enabled sorting of error messages as well as stacktraces

* Minor edits to the documentation

* Small documentation correction

* Minor edits to the documentation

* Log an error for every failed attempt to connect to master

The connection timeout and number of attempts are hardcoded, so a failure will take very long
These log lines will allow to troubleshoot issues with the connection to master

* Minor edits to the documentation

* Minor edits to the documentation

* Minor edits to the documentation

* Stop calling attributes 'properties' in some places.

* Give a better error message when someone accidentally sets User.task instead of User.tasks

* Fix detection of accidental TaskSet.task attribute

* fix spelling in comment

* style: add a report favicon

* Removed cache_timeout kwarg from request_stats_full_history_csv for flask 2.2.0

* temporary change to see logs for py38

* restored resource warning masking

* enabled tracemalloc temporarily

* removed tracemalloc

* Ensure no caching of stats history csv (replaces cache_timeout=None which was removed in locustio#2148)

* Update changelog for 2.10.2 (automatic changelog generation is broken, so CHANGELOG.md is incomplete)

* test: Implement failing test for issue locustio#2135

* fix: Set users_dispatcher to None when test is stopped

* chore: Remove misleading docstring in test

* chore: Do not use intermediate variable for one-use

* perf(test): Decrease test runtime

Co-authored-by: solowalker27 <ryan.subscriptions@me.com>
Co-authored-by: Ryan Warner <ryan.warner@edgecast.com>
Co-authored-by: Lars Holmberg <lars.holmberg@svenskaspel.se>
Co-authored-by: Tom Herrmann <linux@randoom.org>
Co-authored-by: Renan Gomes Barreto <RenanGBarreto@users.noreply.github.com>
Co-authored-by: Tom Herrmann <t.herrmann@sab-engineering.com>
Co-authored-by: Lukas Lanzner <l.lanzner@sab-engineering.com>
Co-authored-by: Dmytro Litvinov <me@dmytrolitvinov.com>
Co-authored-by: Xavier Sosnovsky <xso@sosna.ws>
Co-authored-by: Andy Byrne <andybyrne@users.noreply.github.com>
Co-authored-by: gdm85 <gdm85@users.noreply.github.com>
Co-authored-by: Xavier Sosnovsky <sosna@users.noreply.github.com>
Co-authored-by: Lars Holmberg <lars.holmberg@redshirt.se>
Co-authored-by: Lijiawei <1456470136@qq.com>
Co-authored-by: Michael Nester <mike.nester0@gmail.com>
Co-authored-by: Maxence Boutet <maxenceboutet@outlook.com>
Co-authored-by: Maxence Boutet <52334444+mboutet@users.noreply.github.com>
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

Successfully merging this pull request may close these issues.

None yet

2 participants