Skip to content

Commit 6679ea1

Browse files
committed
Don't import some platform-specific modules
1 parent efdfcfc commit 6679ea1

5 files changed

Lines changed: 31 additions & 35 deletions

File tree

Lib/asyncio/__init__.py

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,9 @@
22

33
import sys
44

5-
# The selectors module is in the stdlib in Python 3.4 but not in 3.3.
6-
# Do this first, so the other submodules can use "from . import selectors".
7-
# Prefer asyncio/selectors.py over the stdlib one, as ours may be newer.
8-
try:
9-
from . import selectors
10-
except ImportError:
11-
import selectors # Will also be exported.
12-
13-
if sys.platform == 'win32':
5+
import selectors
6+
# XXX RustPython TODO: _overlapped
7+
if sys.platform == 'win32' and False:
148
# Similar thing for _overlapped.
159
try:
1610
from . import _overlapped

Lib/asyncio/base_events.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ def __init__(self):
243243
# Identifier of the thread running the event loop, or None if the
244244
# event loop is not running
245245
self._thread_id = None
246-
self._clock_resolution = time.get_clock_info('monotonic').resolution
246+
self._clock_resolution = 1e-06 #time.get_clock_info('monotonic').resolution
247247
self._exception_handler = None
248248
self.set_debug((not sys.flags.ignore_environment
249249
and bool(os.environ.get('PYTHONASYNCIODEBUG'))))

Lib/asyncio/unix_events.py

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -309,16 +309,16 @@ def create_unix_server(self, protocol_factory, path=None, *,
309309
return server
310310

311311

312-
if hasattr(os, 'set_blocking'):
313-
def _set_nonblocking(fd):
314-
os.set_blocking(fd, False)
315-
else:
316-
import fcntl
312+
#if hasattr(os, 'set_blocking'):
313+
# def _set_nonblocking(fd):
314+
# os.set_blocking(fd, False)
315+
#else:
316+
# import fcntl
317317

318-
def _set_nonblocking(fd):
319-
flags = fcntl.fcntl(fd, fcntl.F_GETFL)
320-
flags = flags | os.O_NONBLOCK
321-
fcntl.fcntl(fd, fcntl.F_SETFL, flags)
318+
# def _set_nonblocking(fd):
319+
# flags = fcntl.fcntl(fd, fcntl.F_GETFL)
320+
# flags = flags | os.O_NONBLOCK
321+
# fcntl.fcntl(fd, fcntl.F_SETFL, flags)
322322

323323

324324
class _UnixReadPipeTransport(transports.ReadTransport):
@@ -659,20 +659,20 @@ def _call_connection_lost(self, exc):
659659
self._loop = None
660660

661661

662-
if hasattr(os, 'set_inheritable'):
663-
# Python 3.4 and newer
664-
_set_inheritable = os.set_inheritable
665-
else:
666-
import fcntl
667-
668-
def _set_inheritable(fd, inheritable):
669-
cloexec_flag = getattr(fcntl, 'FD_CLOEXEC', 1)
670-
671-
old = fcntl.fcntl(fd, fcntl.F_GETFD)
672-
if not inheritable:
673-
fcntl.fcntl(fd, fcntl.F_SETFD, old | cloexec_flag)
674-
else:
675-
fcntl.fcntl(fd, fcntl.F_SETFD, old & ~cloexec_flag)
662+
#if hasattr(os, 'set_inheritable'):
663+
# # Python 3.4 and newer
664+
# _set_inheritable = os.set_inheritable
665+
#else:
666+
# import fcntl
667+
#
668+
# def _set_inheritable(fd, inheritable):
669+
# cloexec_flag = getattr(fcntl, 'FD_CLOEXEC', 1)
670+
#
671+
# old = fcntl.fcntl(fd, fcntl.F_GETFD)
672+
# if not inheritable:
673+
# fcntl.fcntl(fd, fcntl.F_SETFD, old | cloexec_flag)
674+
# else:
675+
# fcntl.fcntl(fd, fcntl.F_SETFD, old & ~cloexec_flag)
676676

677677

678678
class _UnixSubprocessTransport(base_subprocess.BaseSubprocessTransport):

Lib/asyncio/windows_events.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414
from . import selector_events
1515
from . import tasks
1616
from . import windows_utils
17-
from . import _overlapped
17+
# XXX RustPython TODO: _overlapped
18+
# from . import _overlapped
1819
from .coroutines import coroutine
1920
from .log import logger
2021

Lib/multiprocessing/connection.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -780,7 +780,8 @@ def XmlClient(*args, **kwds):
780780
# Wait
781781
#
782782

783-
if sys.platform == 'win32':
783+
# XXX RustPython TODO: implement all the functions in this block
784+
if sys.platform == 'win32' and False:
784785

785786
def _exhaustive_wait(handles, timeout):
786787
# Return ALL handles which are currently signalled. (Only

0 commit comments

Comments
 (0)