New submission from Barney Stratford <barney_stratf...@fastmail.fm>:
import socket self.__socket = socket.create_connection ([host, port], 10000) value = self.__socket.recv (4096) This code sometimes hangs despite having a non-None timeout specified. GDB says: (gdb) bt #0 0x76d33c94 in __GI___poll (fds=0x7ea55148, nfds=1, timeout=10000) at ../sysdeps/unix/sysv/linux/poll.c:29 #1 0x001e8014 in poll (__timeout=<optimized out>, __nfds=<optimized out>, __fds=<optimized out>, __fds=<optimized out>, __nfds=<optimized out>, __timeout=<optimized out>) at /usr/include/arm-linux-gnueabihf/bits/poll2.h:46 #2 internal_select (writing=writing@entry=0, interval=<optimized out>, connect=0, connect@entry=4156908, s=<optimized out>) at ../Modules/socketmodule.c:745 #3 0x001ec588 in sock_call_ex (s=s@entry=0x76979d68, writing=writing@entry=0, sock_func=sock_func@entry=0x1e736c <sock_recv_impl>, data=0x7ea551b0, data@entry=0x7ea551a8, connect=connect@entry=0, err=err@entry=0x0, timeout=10000000000) at ../Modules/socketmodule.c:840 #4 0x001ed394 in sock_call (data=0x7ea551a8, func=0x1e736c <sock_recv_impl>, writing=0, s=0x76979d68) at ../Modules/socketmodule.c:3287 #5 sock_recv_guts (s=s@entry=0x76979d68, cbuf=<optimized out>, len=<optimized out>, flags=<optimized out>) at ../Modules/socketmodule.c:3287 #6 0x001ed51c in sock_recv (s=0x76979d68, args=<optimized out>) at ../Modules/socketmodule.c:3318 Googling for this problem turned up this: https://stackoverflow.com/questions/56038224/poll-waits-indefinitely-although-timeout-is-specified If we look at socket module.c line 756 (Python 3.7.9 version), we see that we're indeed not checking for the pollfd.revents, and are therefore missing socket errors. PR coming up in a few days. ---------- components: Library (Lib) messages: 382145 nosy: Barney Stratford priority: normal severity: normal status: open title: Socket.recv hangs type: crash versions: Python 3.7 _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue42513> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com