]> git.ipfire.org Git - thirdparty/tornado.git/commitdiff
iostream,platform: Remove _set_nonblocking function 2884/head
authorBen Darnell <ben@cockroachlabs.com>
Fri, 26 Jun 2020 22:57:31 +0000 (18:57 -0400)
committerBen Darnell <ben@cockroachlabs.com>
Fri, 26 Jun 2020 22:57:31 +0000 (18:57 -0400)
This functionality is now provided directly in the `os` module.

tornado/iostream.py
tornado/platform/posix.py [deleted file]

index 1fe26ae6a8e3d13d29fa432502f8c286e51df823..92834e50a5b639aff663472607a35af74a518ac4 100644 (file)
@@ -59,11 +59,6 @@ if typing.TYPE_CHECKING:
 
 _IOStreamType = TypeVar("_IOStreamType", bound="IOStream")
 
-try:
-    from tornado.platform.posix import _set_nonblocking
-except ImportError:
-    _set_nonblocking = None  # type: ignore
-
 # These errnos indicate that a connection has been abruptly terminated.
 # They should be caught and handled less noisily than other errors.
 _ERRNO_CONNRESET = (errno.ECONNRESET, errno.ECONNABORTED, errno.EPIPE, errno.ETIMEDOUT)
@@ -1620,12 +1615,14 @@ class PipeIOStream(BaseIOStream):
     by `os.pipe`) rather than an open file object.  Pipes are generally
     one-way, so a `PipeIOStream` can be used for reading or writing but not
     both.
+
+    ``PipeIOStream`` is only available on Unix-based platforms.
     """
 
     def __init__(self, fd: int, *args: Any, **kwargs: Any) -> None:
         self.fd = fd
         self._fio = io.FileIO(self.fd, "r+")
-        _set_nonblocking(fd)
+        os.set_blocking(fd, False)
         super(PipeIOStream, self).__init__(*args, **kwargs)
 
     def fileno(self) -> int:
diff --git a/tornado/platform/posix.py b/tornado/platform/posix.py
deleted file mode 100644 (file)
index e4699a6..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-#
-# Copyright 2011 Facebook
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-#     http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-"""Posix implementations of platform-specific functionality."""
-
-import fcntl
-import os
-
-
-def _set_nonblocking(fd: int) -> None:
-    flags = fcntl.fcntl(fd, fcntl.F_GETFL)
-    fcntl.fcntl(fd, fcntl.F_SETFL, flags | os.O_NONBLOCK)