Skip to content

Commit

Permalink
tests: linkcheck: refactor connection-pool contention test to use int…
Browse files Browse the repository at this point in the history
…erleaved threads
  • Loading branch information
jayaddison committed May 9, 2023
1 parent 589bca5 commit 2ba1856
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions tests/test_build_linkcheck.py
Original file line number Diff line number Diff line change
Expand Up @@ -687,21 +687,23 @@ def test_connection_contention(get_adapter, app, capsys):

# Create single-hyperlink-consumer threads
with http_server(make_redirect_handler(support_head=True)):
begin, checked = time.time(), []
while time.time() < begin + 5 and len(checked) < link_count:
worker = HyperlinkAvailabilityCheckWorker(
begin, threads, checked = time.time(), [], []
threads = [
HyperlinkAvailabilityCheckWorker(
env=app.env,
config=app.config,
rqueue=rqueue,
wqueue=wqueue,
rate_limits={},
)

worker.start()
result = rqueue.get(timeout=5)
worker.join(timeout=0)

checked.append(result)
for _ in range(10 * 5)
]
for thread in threads:
thread.start()
while time.time() < begin + 5 and len(checked) < link_count:
checked.append(rqueue.get(timeout=5))
for thread in threads:
thread.join(timeout=0)

# Ensure that all items were consumed within the time limit
_, stderr = capsys.readouterr()
Expand Down

0 comments on commit 2ba1856

Please sign in to comment.