Chris Angelico <ros...@gmail.com>: > On Thu, Nov 24, 2016 at 10:14 PM, Marko Rauhamaa <ma...@pacujo.net> wrote: >> When you use threads, you call read(2) in the blocking mode. Then the >> read(2) operation will block "for ever." There's no clean way to >> cancel the system call. > > Signals will usually interrupt system calls, causing them to return > EINTR. There are exceptions (the aforementioned uninterruptible calls, > but they're not available in nonblocking form, so they're the same for > threads and coroutines), but the bulk of system calls will halt > cleanly on receipt of a signal. And yes, you CAN send signals to > specific threads; there are limitations, but for a language like > Python, there's no difficulty in having a single disposition for (say) > SIGINT, and then using thread signalling to figure out which thread > should have KeyboardInterrupt raised in it.
Yes, pthread_kill(3) has been made available in Python-3.3, I'm noticing. Also: Changed in version 3.5: Python now retries system calls when a syscall is interrupted by a signal, except if the signal handler raises an exception (see PEP 475 for the rationale), instead of raising InterruptedError. <URL: https://docs.python.org/3/library/exceptions.html#Interrupt edError> Marko -- https://mail.python.org/mailman/listinfo/python-list