pytest-dev / pytest-timeout

MIT License
213 stars 64 forks source link

Status of support for timeouts in native code #141

Closed bgschaid closed 1 year ago

bgschaid commented 1 year ago

I'm currently porting an algorithm that takes quite long from Python to Rust to be called from Python. To catch errors like infinite loops I intended to use this plugin. Problem is that when the execution is inside the Rust code no timeout is triggered.

I understand that this is probably not supported (I was suspicious about this but tried anyway as I found nothing in the documentation) and this is OK but it would be nice if there was a short statement about this in the README (something like "does not work with libraries of native code" or "only works if the native code at some point releases the GIL")

bgschaid commented 1 year ago

OK. Fixed it for me. The Rust-code didn't check for signals.

So the remark should be something like "this only works for native code that regularly checks for signals (either explicitly or implicitly)"

flub commented 1 year ago

Hum, you need to yield to python code somehow. The best, by which I mean most reliable, approach would be to use the "thread" method rather than signal in this case.