MCPcopy Create free account
hub / github.com/simplejson/simplejson / scenario_shared_encoder_distinct_inputs

Function scenario_shared_encoder_distinct_inputs

tsan_stress_simplejson.py:322–343  ·  view source on GitHub ↗

N threads share ONE encoder; distinct objects. markers/key_memo races.

()

Source from the content-addressed store, hash-verified

320
321
322def scenario_shared_encoder_distinct_inputs():
323 """N threads share ONE encoder; distinct objects. markers/key_memo races."""
324 encoder = _make_shared_encoder()
325
326 def make_worker(tid):
327 def worker():
328 deadline = time.monotonic() + DURATION
329 for i in range(ITERATIONS):
330 obj = _make_distinct_object(tid * 1_000_000 + i)
331 try:
332 encoder(obj, 0)
333 except Exception:
334 pass
335 if time.monotonic() > deadline:
336 break
337 return worker
338
339 run_scenario(
340 "shared encoder, distinct inputs (markers / key_memo races)",
341 [make_worker(i) for i in range(THREADS)],
342 [1] * THREADS,
343 )
344
345
346def scenario_shared_encoder_shared_dict():

Callers

nothing calls this directly

Calls 3

_make_shared_encoderFunction · 0.85
run_scenarioFunction · 0.85
make_workerFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…