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

Merged
merged 6 commits into from
Nov 14, 2024
Merged

Introduce gevent request timeout #310

merged 6 commits into from
Nov 14, 2024

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

coveralls commented Oct 31, 2024

Pull Request Test Coverage Report for Build 11819057268

Details

  • 66 of 71 (92.96%) changed or added relevant lines in 35 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-0.05%) to 93.765%

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 11816539068: -0.05%
Covered Lines: 6376
Relevant Lines: 6800

💛 - Coveralls

server/application.py Show resolved Hide resolved
Copy link

@mostlyAtNight mostlyAtNight left a comment

Choose a reason for hiding this comment

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

a few comments to go through but looks great

server/application.py Show resolved Hide resolved
server/config.py Show resolved Hide resolved
server/mergin/app.py Outdated Show resolved Hide resolved
server/mergin/tests/test_middleware.py Show resolved Hide resolved
@MarcelGeo MarcelGeo merged commit 916fb17 into develop Nov 14, 2024
4 checks passed
@MarcelGeo MarcelGeo deleted the gevent_timeout branch November 14, 2024 13:08
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.

4 participants