Nat's patch for making greenio successfully import under Windows by deferring the import of fcntl.
This commit is contained in:
@@ -32,7 +32,6 @@ import errno
|
|||||||
import os
|
import os
|
||||||
import socket
|
import socket
|
||||||
from socket import socket as _original_socket
|
from socket import socket as _original_socket
|
||||||
import fcntl
|
|
||||||
import time
|
import time
|
||||||
|
|
||||||
|
|
||||||
@@ -169,14 +168,17 @@ def file_send(fd, data):
|
|||||||
|
|
||||||
|
|
||||||
def set_nonblocking(fd):
|
def set_nonblocking(fd):
|
||||||
## Socket
|
try:
|
||||||
if hasattr(fd, 'setblocking'):
|
setblocking = fd.setblocking
|
||||||
fd.setblocking(0)
|
except AttributeError:
|
||||||
## File
|
# This version of Python predates socket.setblocking()
|
||||||
else:
|
import fcntl
|
||||||
fileno = fd.fileno()
|
fileno = fd.fileno()
|
||||||
flags = fcntl.fcntl(fileno, fcntl.F_GETFL)
|
flags = fcntl.fcntl(fileno, fcntl.F_GETFL)
|
||||||
fcntl.fcntl(fileno, fcntl.F_SETFL, flags | os.O_NONBLOCK)
|
fcntl.fcntl(fileno, fcntl.F_SETFL, flags | os.O_NONBLOCK)
|
||||||
|
else:
|
||||||
|
# socket supports setblocking()
|
||||||
|
setblocking(0)
|
||||||
|
|
||||||
|
|
||||||
class GreenSocket(object):
|
class GreenSocket(object):
|
||||||
|
Reference in New Issue
Block a user