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

Introduce gevent request timeout #310

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open

Introduce gevent request timeout #310

wants to merge 3 commits into from

Conversation

varmar05
Copy link
Contributor

Currently we do not have any bounds in case we run server with gevent worker type. In case client gave up on connection server still might be processing request. Also if request is greenlet safe (as it should be!) it can take long time to finish since it yields to gevent hub and standard gunicorn timeout is not applied here.

This PR introduces custom timeout via middleware to cut the request early enough in case of gevent. There are two new related variables GEVENT_WORKER and GEVENT_REQUEST_TIMEOUT.

Logs from a dummy test

[ERROR] [23194] Gevent worker: Request /ping timed out
[ACCESS] - GET /ping  HTTP/1.1 502 11 - "Mozilla/5.0 (X11; Linux x86_64) ..." 1003113 <23194>

@MarcelGeo MarcelGeo marked this pull request as draft October 30, 2024 08:15
@MarcelGeo MarcelGeo marked this pull request as ready for review October 31, 2024 12:51
@coveralls
Copy link

Pull Request Test Coverage Report for Build 11614372031

Details

  • 33 of 38 (86.84%) changed or added relevant lines in 3 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-0.04%) to 93.756%

Changes Missing Coverage Covered Lines Changed/Added Lines %
server/mergin/tests/test_middleware.py 16 17 94.12%
server/mergin/app.py 15 19 78.95%
Totals Coverage Status
Change from base Build 11595329168: -0.04%
Covered Lines: 6352
Relevant Lines: 6775

💛 - Coveralls


if not os.getenv("NO_MONKEY_PATCH", False):
Copy link
Contributor

@MarcelGeo MarcelGeo Nov 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to refactor this NO_MONKEY_PATCH variable in whole system? I'm not sure, if we want to use it in private repo.

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.

3 participants