Skip to content

Commit

Permalink
try to fix some socket errors on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
baskiton committed Mar 23, 2024
1 parent 24265c5 commit c72aea8
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions SatsDecoder/ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import select
import socket as sk
import struct
import sys
import threading
import tkinter as tk
import urllib
Expand Down Expand Up @@ -631,9 +632,14 @@ def _client(self):
def _recvall(conn, n):
ret = bytearray()
while len(ret) < n:
x = conn.recv(n - len(ret))
if not x:
return b''
try:
x = conn.recv(n - len(ret))
if not x:
return b''
except OSError as e:
if e.errno in (errno.EAGAIN, errno.EWOULDBLOCK, sys.platform == 'win32' and errno.WSAEWOULDBLOCK):
continue
raise
ret.extend(x)
return ret

Expand All @@ -649,9 +655,9 @@ def _receive(self, conn):
except AttributeError:
return 1
except OSError as e:
if e.errno == errno.EAGAIN:
if e.errno in (errno.EAGAIN, errno.EWOULDBLOCK, sys.platform == 'win32' and errno.WSAEWOULDBLOCK):
return
if e.errno != errno.EBADF and conn.fileno() != -1:
if e.errno not in (errno.EBADF, sys.platform == 'win32' and errno.WSAEBADF) and conn.fileno() != -1:
messagebox.showerror(message='%s: %s (%s)' % (self.name, e, conn))
return 1

Expand Down

0 comments on commit c72aea8

Please sign in to comment.