Commit e36eff2
fix: make interrupt test reliable on Python 3.11
PyThreadState_SetAsyncExc only delivers exceptions when the thread is
executing Python bytecode, not while in native (Rust/C) code. The
previous test had two issues causing flakiness on Python 3.11:
1. The interrupt fired before df.collect() entered the UDF, while the
thread was still in native code where async exceptions are ignored.
2. time.sleep(2.0) is a single C call where async exceptions are not
checked — they're only checked between bytecode instructions.
Fix by adding a threading.Event so the interrupt waits until the UDF is
actually executing Python code, and by sleeping in small increments so
the eval loop has opportunities to check for pending exceptions.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>1 parent fca0122 commit e36eff2
1 file changed
Lines changed: 19 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3416 | 3416 | | |
3417 | 3417 | | |
3418 | 3418 | | |
| 3419 | + | |
| 3420 | + | |
| 3421 | + | |
3419 | 3422 | | |
3420 | 3423 | | |
3421 | | - | |
3422 | | - | |
| 3424 | + | |
| 3425 | + | |
| 3426 | + | |
| 3427 | + | |
| 3428 | + | |
| 3429 | + | |
| 3430 | + | |
3423 | 3431 | | |
3424 | 3432 | | |
3425 | 3433 | | |
| |||
3453 | 3461 | | |
3454 | 3462 | | |
3455 | 3463 | | |
| 3464 | + | |
3456 | 3465 | | |
3457 | 3466 | | |
3458 | 3467 | | |
| |||
3464 | 3473 | | |
3465 | 3474 | | |
3466 | 3475 | | |
| 3476 | + | |
| 3477 | + | |
| 3478 | + | |
| 3479 | + | |
| 3480 | + | |
| 3481 | + | |
| 3482 | + | |
| 3483 | + | |
3467 | 3484 | | |
3468 | 3485 | | |
3469 | 3486 | | |
| |||
0 commit comments