Message223708
I talked with Charles-François. He doesn't like the idea of a new function because it would be harder to write portable code: which function should be used? signal.set_wakeup_fd() already works with sockets on UNIX.
Here is a new patch version 4 which tries to combine previous patchs:
- don't touch anything to existing code on UNIX. Keep the sig_atomic_t type for wakeup_fd and continue to use write() on sockets.
- on Windows, use a new "wakeup" structure to store the file descriptor or socket handle (use the SOCKET_T type) and the last send() errors (errno and GetLastError())
- on Windows, use getsockopt(fd, SOL_SOCKET, SO_ERROR, ...) to check if fd is a socket: the function fails with WSAENOTSOCK if fd is not a socket.
- on Windows, PySignal_SetWakeupFd() only supports file descriptors. The function returns -1 if signal.set_wakeup_fd() was called with a socket handler, because the return type (int) is too small to store a socket handle (need type SOCKET_T) and we cannot change the prototype of this public API.
Reminder: the purpose of the whole patch is to be able to wakeup an event loop based on select.select() on Windows. select() only supports sockets on Windows.
Notes:
- we still need to add a dependency to the WinSock library
- the test are still skipped on Windows, I will work on a new patch to make the file descriptor or socket non-blocking and to run more wakeup fd tests on Windows
- if send() fails twice, the error is only reported once until report_wakeup_send_error() is called to consume the error. Anything, if send() failed, it will probably fail again quickly, there is no need to flood the terminal with these errors. |
|
Date |
User |
Action |
Args |
2014-07-22 23:43:27 | vstinner | set | recipients:
+ vstinner, gvanrossum, loewis, pitrou, neologix, python-dev, yselivanov |
2014-07-22 23:43:27 | vstinner | set | messageid: <1406072607.24.0.679789058549.issue22018@psf.upfronthosting.co.za> |
2014-07-22 23:43:27 | vstinner | link | issue22018 messages |
2014-07-22 23:43:26 | vstinner | create | |
|