Other solutions did not work for me. Here is a hacky solution that did work for me:
import select
_ORIGINAL_SELECT = select.select
def _safe_select(*args, **kwargs):
try:
return _ORIGINAL_SELECT(*args, **kwargs)
except OSError as e:
if e.errno == 10038:
return [], [], []
else:
raise
select.select = _safe_select
This code prevents select.select() to raise the OSError 10038