Skip to content

Commit 32e5ba4

Browse files
committed
Simplify test
1 parent 1ecc7df commit 32e5ba4

1 file changed

Lines changed: 2 additions & 12 deletions

File tree

Lib/test/test_ssl.py

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1614,14 +1614,7 @@ def test_sni_callback_race(self):
16141614
# crash (use-after-free on the callback in free-threaded builds).
16151615
client_ctx, server_ctx, hostname = testing_context()
16161616

1617-
def make_callback(n):
1618-
def sni_cb(_ssl_obj, _servername, _ctx):
1619-
if n == -1 and _servername == "":
1620-
raise AssertionError("unreachable")
1621-
return None
1622-
return sni_cb
1623-
1624-
server_ctx.sni_callback = make_callback(0)
1617+
server_ctx.sni_callback = lambda *a: None
16251618
done = threading.Event()
16261619

16271620
def do_handshakes():
@@ -1652,12 +1645,9 @@ def do_handshakes():
16521645
c_in.write(s_out.read())
16531646

16541647
def toggle_callback():
1655-
i = 0
16561648
while not done.is_set():
1657-
server_ctx.sni_callback = make_callback(i)
1649+
server_ctx.sni_callback = lambda *a: None
16581650
server_ctx.sni_callback = None
1659-
server_ctx.sni_callback = make_callback(-i)
1660-
i += 1
16611651

16621652
workers = max(4, (os.cpu_count() or 4) * 2)
16631653
threads = [threading.Thread(target=do_handshakes)

0 commit comments

Comments
 (0)