summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorDirk Engling <erdgeist@erdgeist.org>2026-11-06 03:01:46 +0100
committerDirk Engling <erdgeist@erdgeist.org>2026-11-06 03:01:46 +0100
commit8bae93ce181086769175e5c3fb0f0ef66fb9ca89 (patch)
treeda86b766bd37f1a71d0847fd3ebbd93b1f95ec76 /tests
parent2cecc9da20afb55613589dafc854e9f4d1a74069 (diff)
Stop reading a connection a worker has taken over
Diffstat (limited to 'tests')
-rw-r--r--tests/integration/test_keepalive.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/tests/integration/test_keepalive.py b/tests/integration/test_keepalive.py
index 01f02a5..2c724fc 100644
--- a/tests/integration/test_keepalive.py
+++ b/tests/integration/test_keepalive.py
@@ -7,6 +7,7 @@ the request has moved on, so whether to keep the connection has to be
7remembered on the connection itself. 7remembered on the connection itself.
8""" 8"""
9 9
10import time
10import unittest 11import unittest
11import urllib.parse 12import urllib.parse
12 13
@@ -106,6 +107,24 @@ class KeepAlive(TrackerTestCase):
106 finally: 107 finally:
107 c.close() 108 c.close()
108 109
110 def test_a_split_request_answered_by_a_worker_does_not_spin(self):
111 """A reply that a worker produces does not go through the send path,
112 so the request stays in the buffer the read loop is reading. The loop
113 used to find the same request again on every pass, queue a task for
114 it, and never hand the thread back to the event loop."""
115 for path in ("/stats", "/scrape"):
116 c = self.tracker.connect()
117 try:
118 c.sock.sendall(("GET %s HTTP/1.1\r\nConnection: keep-alive\r\n" % path).encode())
119 time.sleep(0.2)
120 c.sock.sendall(b"\r\n")
121 self.assertIn(b"200", c.reply()[0], "%s was not answered" % path)
122 finally:
123 c.close()
124
125 answer = self.tracker.announce(self.hash_for("after-" + path), port=6881, left=0)
126 self.assertNotIn(b"failure reason", answer, "the tracker stopped serving after %s" % path)
127
109 128
110if __name__ == "__main__": 129if __name__ == "__main__":
111 unittest.main() 130 unittest.main()