2
0
mirror of https://opendev.org/x/pyghmi synced 2025-02-20 12:30:48 +00:00

Bypass eventlet sendto when detected

Sending a udp datagram doesn't block long enough to be bothered.  On
the flipside, the filehandle sharing can throw eventlet for a loop in
some environments and circumstances.

Change-Id: I2d6f8b79f0e49c5f21b3b0cf1b9956443ece7eea
This commit is contained in:
Jarrod Johnson 2017-04-11 13:44:15 -04:00
parent 324cc6a344
commit b9b9620a9d

View File

@ -151,13 +151,19 @@ def _io_wait(timeout, myaddr=None, evq=None):
# it piggy back on the select() in the io thread, which is a truly
# lazy wait even with eventlet involvement
if deadline < selectdeadline:
iosockets[0].sendto(b'\x01', (myself, iosockets[0].getsockname()[1]))
intsock = iosockets[0]
if hasattr(intsock, 'fd'):
# if in eventlet, go for the true sendto, which is less glitchy
intsock = intsock.fd
intsock.sendto(b'\x01', (myself, iosockets[0].getsockname()[1]))
evt.wait()
def _io_sendto(mysocket, packet, sockaddr):
#Want sendto to act reasonably sane..
mysocket.setblocking(1)
if hasattr(mysocket, 'fd'):
mysocket = mysocket.fd
try:
mysocket.sendto(packet, sockaddr)
except Exception: