Commit 8bd6e622 authored by Jason Madden's avatar Jason Madden

workaround windows disallowing three empty arguments to select.

parent a06e2ff4
...@@ -4,6 +4,8 @@ Waiting for I/O completion. ...@@ -4,6 +4,8 @@ Waiting for I/O completion.
""" """
from __future__ import absolute_import from __future__ import absolute_import
import sys
from gevent.event import Event from gevent.event import Event
from gevent.hub import get_hub from gevent.hub import get_hub
from gevent.hub import sleep as _g_sleep from gevent.hub import sleep as _g_sleep
...@@ -14,7 +16,13 @@ from gevent._util import copy_globals ...@@ -14,7 +16,13 @@ from gevent._util import copy_globals
from gevent._util import _NONE from gevent._util import _NONE
from errno import EINTR from errno import EINTR
from select import select as _original_select if sys.platform.startswith('win32'):
def _original_select(_r, _w, _x, _t):
# windows cant handle three empty lists, but we've always
# accepted that, so don't try the compliance check on windows
return ((), (), ())
else:
from select import select as _original_select
try: try:
from select import poll as original_poll from select import poll as original_poll
...@@ -128,6 +136,7 @@ def select(rlist, wlist, xlist, timeout=None): # pylint:disable=unused-argument ...@@ -128,6 +136,7 @@ def select(rlist, wlist, xlist, timeout=None): # pylint:disable=unused-argument
# (Because libev tends to just return them as ready...) # (Because libev tends to just return them as ready...)
# We accept the *xlist* here even though we can't below because this is all about # We accept the *xlist* here even though we can't below because this is all about
# error handling. # error handling.
sel_results = ((), (), ())
try: try:
sel_results = _original_select(rlist, wlist, xlist, 0) sel_results = _original_select(rlist, wlist, xlist, 0)
except error as e: except error as e:
...@@ -135,7 +144,6 @@ def select(rlist, wlist, xlist, timeout=None): # pylint:disable=unused-argument ...@@ -135,7 +144,6 @@ def select(rlist, wlist, xlist, timeout=None): # pylint:disable=unused-argument
if enumber != EINTR: if enumber != EINTR:
# Ignore interrupted syscalls # Ignore interrupted syscalls
raise raise
sel_results = ((), (), ())
if sel_results[0] or sel_results[1] or sel_results[2]: if sel_results[0] or sel_results[1] or sel_results[2]:
# If we actually had stuff ready, go ahead and return it. No need # If we actually had stuff ready, go ahead and return it. No need
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment