(selenium)
| 406 | @requires_jspi |
| 407 | @pytest.mark.requires_dynamic_linking |
| 408 | def test_nested_syncify(selenium): |
| 409 | res = selenium.run_js( |
| 410 | """ |
| 411 | async function f1() { |
| 412 | await sleep(30); |
| 413 | return await g1.callPromising(); |
| 414 | } |
| 415 | async function f2() { |
| 416 | await sleep(30); |
| 417 | return await g2.callPromising(); |
| 418 | } |
| 419 | async function getStuff() { |
| 420 | await sleep(30); |
| 421 | return "gotStuff"; |
| 422 | } |
| 423 | pyodide.globals.set("f1", f1); |
| 424 | pyodide.globals.set("f2", f2); |
| 425 | pyodide.globals.set("getStuff", getStuff); |
| 426 | |
| 427 | pyodide.runPython(` |
| 428 | from pyodide.ffi import run_sync |
| 429 | from js import sleep |
| 430 | def g(): |
| 431 | run_sync(sleep(25)) |
| 432 | return run_sync(f1()) |
| 433 | |
| 434 | def g1(): |
| 435 | run_sync(sleep(25)) |
| 436 | return run_sync(f2()) |
| 437 | |
| 438 | def g2(): |
| 439 | run_sync(sleep(25)) |
| 440 | return run_sync(getStuff()) |
| 441 | `); |
| 442 | const l = pyodide.runPython("l = []; l") |
| 443 | const g = pyodide.globals.get("g"); |
| 444 | const g1 = pyodide.globals.get("g1"); |
| 445 | const g2 = pyodide.globals.get("g2"); |
| 446 | const p = []; |
| 447 | p.push(g.callPromising().then((res) => l.append(res))); |
| 448 | p.push(pyodide.runPythonAsync(` |
| 449 | from js import sleep |
| 450 | for i in range(20): |
| 451 | run_sync(sleep(9)) |
| 452 | l.append(i) |
| 453 | `)); |
| 454 | await Promise.all(p); |
| 455 | const res = l.toJs(); |
| 456 | for(let p of [l, g, g1, g2]) { |
| 457 | p.destroy() |
| 458 | } |
| 459 | return res; |
| 460 | """ |
| 461 | ) |
| 462 | assert "gotStuff" in res |
| 463 | del res[res.index("gotStuff")] |
| 464 | assert res == list(range(20)) |
| 465 |
nothing calls this directly
no test coverage detected
searching dependent graphs…