Commit 4a1c11c8 authored by Fred Drake's avatar Fred Drake

Clean up FCNTL imports differently, and catch the remaining import of that

module.  My *hope* is that this takes care of the single deprecation warning
produced when running the regression tests on the trunk with Python 2.2.
parent 3719aac9
...@@ -66,13 +66,13 @@ except: ...@@ -66,13 +66,13 @@ except:
# processes from Zope code. Thanks to Dieter Maurer for this. # processes from Zope code. Thanks to Dieter Maurer for this.
try: try:
import fcntl import fcntl
if not (hasattr(fcntl, 'F_SETFD') and hasattr(fcntl, 'FD_CLOEXEC')): try:
# hack to be compatible with Python versions pre-2.2 from fcntl import F_SETFD, FD_CLOEXEC
import FCNTL except ImportError:
fcntl.F_SETFD = FCNTL.F_SETFD from FCNTL import F_SETFD, FD_CLOEXEC
fcntl.FD_CLOEXEC = FCNTL.FD_CLOEXEC
def requestCloseOnExec(sock): def requestCloseOnExec(sock):
try: fcntl.fcntl(sock.fileno(), fcntl.F_SETFD, fcntl.FD_CLOEXEC) try: fcntl.fcntl(sock.fileno(), F_SETFD, FD_CLOEXEC)
except: pass except: pass
except (ImportError, AttributeError): except (ImportError, AttributeError):
......
# -*- Mode: Python; tab-width: 4 -*- # -*- Mode: Python; tab-width: 4 -*-
VERSION_STRING = "$Id: thread_channel.py,v 1.3 2001/05/01 11:45:27 andreas Exp $" VERSION_STRING = "$Id: thread_channel.py,v 1.4 2002/02/27 04:40:20 fdrake Exp $"
# This will probably only work on Unix. # This will probably only work on Unix.
...@@ -14,12 +14,16 @@ import asyncore ...@@ -14,12 +14,16 @@ import asyncore
import asynchat import asynchat
import fcntl import fcntl
import FCNTL
import os import os
import socket import socket
import string import string
import thread import thread
try:
from fcntl import F_GETFL, F_SETFL, O_NDELAY
except ImportError:
from FCNTL import F_GETFL, F_SETFL, O_NDELAY
# this channel slaves off of another one. it starts a thread which # this channel slaves off of another one. it starts a thread which
# pumps its output through the 'write' side of the pipe. The 'read' # pumps its output through the 'write' side of the pipe. The 'read'
# side of the pipe will then notify us when data is ready. We push # side of the pipe will then notify us when data is ready. We push
...@@ -42,8 +46,8 @@ class thread_channel (asyncore.file_dispatcher): ...@@ -42,8 +46,8 @@ class thread_channel (asyncore.file_dispatcher):
# The read side of the pipe is set to non-blocking I/O; it is # The read side of the pipe is set to non-blocking I/O; it is
# 'owned' by medusa. # 'owned' by medusa.
flags = fcntl.fcntl (rfd, FCNTL.F_GETFL, 0) flags = fcntl.fcntl (rfd, F_GETFL, 0)
fcntl.fcntl (rfd, FCNTL.F_SETFL, flags | FCNTL.O_NDELAY) fcntl.fcntl (rfd, F_SETFL, flags | O_NDELAY)
# The write side of the pipe is left in blocking mode; it is # The write side of the pipe is left in blocking mode; it is
# 'owned' by the thread. However, we wrap it up as a file object. # 'owned' by the thread. However, we wrap it up as a file object.
......
...@@ -66,13 +66,13 @@ except: ...@@ -66,13 +66,13 @@ except:
# processes from Zope code. Thanks to Dieter Maurer for this. # processes from Zope code. Thanks to Dieter Maurer for this.
try: try:
import fcntl import fcntl
if not (hasattr(fcntl, 'F_SETFD') and hasattr(fcntl, 'FD_CLOEXEC')): try:
# hack to be compatible with Python versions pre-2.2 from fcntl import F_SETFD, FD_CLOEXEC
import FCNTL except ImportError:
fcntl.F_SETFD = FCNTL.F_SETFD from FCNTL import F_SETFD, FD_CLOEXEC
fcntl.FD_CLOEXEC = FCNTL.FD_CLOEXEC
def requestCloseOnExec(sock): def requestCloseOnExec(sock):
try: fcntl.fcntl(sock.fileno(), fcntl.F_SETFD, fcntl.FD_CLOEXEC) try: fcntl.fcntl(sock.fileno(), F_SETFD, FD_CLOEXEC)
except: pass except: pass
except (ImportError, AttributeError): except (ImportError, AttributeError):
......
# -*- Mode: Python; tab-width: 4 -*- # -*- Mode: Python; tab-width: 4 -*-
VERSION_STRING = "$Id: thread_channel.py,v 1.3 2001/05/01 11:45:27 andreas Exp $" VERSION_STRING = "$Id: thread_channel.py,v 1.4 2002/02/27 04:40:20 fdrake Exp $"
# This will probably only work on Unix. # This will probably only work on Unix.
...@@ -14,12 +14,16 @@ import asyncore ...@@ -14,12 +14,16 @@ import asyncore
import asynchat import asynchat
import fcntl import fcntl
import FCNTL
import os import os
import socket import socket
import string import string
import thread import thread
try:
from fcntl import F_GETFL, F_SETFL, O_NDELAY
except ImportError:
from FCNTL import F_GETFL, F_SETFL, O_NDELAY
# this channel slaves off of another one. it starts a thread which # this channel slaves off of another one. it starts a thread which
# pumps its output through the 'write' side of the pipe. The 'read' # pumps its output through the 'write' side of the pipe. The 'read'
# side of the pipe will then notify us when data is ready. We push # side of the pipe will then notify us when data is ready. We push
...@@ -42,8 +46,8 @@ class thread_channel (asyncore.file_dispatcher): ...@@ -42,8 +46,8 @@ class thread_channel (asyncore.file_dispatcher):
# The read side of the pipe is set to non-blocking I/O; it is # The read side of the pipe is set to non-blocking I/O; it is
# 'owned' by medusa. # 'owned' by medusa.
flags = fcntl.fcntl (rfd, FCNTL.F_GETFL, 0) flags = fcntl.fcntl (rfd, F_GETFL, 0)
fcntl.fcntl (rfd, FCNTL.F_SETFL, flags | FCNTL.O_NDELAY) fcntl.fcntl (rfd, F_SETFL, flags | O_NDELAY)
# The write side of the pipe is left in blocking mode; it is # The write side of the pipe is left in blocking mode; it is
# 'owned' by the thread. However, we wrap it up as a file object. # 'owned' by the thread. However, we wrap it up as a file object.
......
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