3 ms·
The same kind of issue prevents Celery (a python task queue) "soft timeout" feature from working reliably. It throws an exception _anywhere_ in the worker proc
by constantin0 2y ago
The same kind of issue prevents Celery (a python task queue) "soft timeout" feature from working reliably.
It throws an exception _anywhere_ in the worker process to signal the timeout, but in practice the exception is often eaten by too-generic except blocks in library code and never reaches user code.
An interesting solution is structured concurrency because it introduces "raise-safe" points (the "await"s), but the ecosystem is not there yet.
- kgeist 2y ago>but in practice the exception is often eaten by too-generic except blocks in library code and never reaches user code Interesting, C# has a special case for this: >ThreadAbortException is a special exception that can be caught, but it will automatically be raised again at the end of the catch block.
- deleted 2y ago[deleted]
- nijave 2y agoI like Python but it's definitely a pain when it comes to request cancellation I saw a StackOverflow post about some code that only worked on Linux and not Windows and it turns out sleeps on Windows are implemented using an uninterruptible API (I think there are other APIs on Windows but the developers of Python picked the one they did since it was simple/low overhead) * Maybe not a perfect description but it was something about a non interruptible Windows API Not sure if they changed it but iirc Python was using a less precise timer on Windows that couldn't sleep less than 14-15ms as well