Commit 4020a482 authored by Denis Bilenko's avatar Denis Bilenko

rename os_read/os_write/os_fork into _read/_write/_fork

parent 01a8a2a6
...@@ -3,7 +3,7 @@ import sys ...@@ -3,7 +3,7 @@ import sys
import os import os
from gevent.hub import get_hub from gevent.hub import get_hub
from gevent.socket import EBADF from gevent.socket import EBADF
from gevent.os import os_read, os_write, ignored_errors from gevent.os import _read, _write, ignored_errors
try: try:
...@@ -98,7 +98,7 @@ else: ...@@ -98,7 +98,7 @@ else:
bytes_written = 0 bytes_written = 0
while bytes_written < bytes_total: while bytes_written < bytes_total:
try: try:
bytes_written += os_write(fileno, _get_memory(data, bytes_written)) bytes_written += _write(fileno, _get_memory(data, bytes_written))
except (IOError, OSError): except (IOError, OSError):
code = sys.exc_info()[1].args[0] code = sys.exc_info()[1].args[0]
if code not in ignored_errors: if code not in ignored_errors:
...@@ -109,7 +109,7 @@ else: ...@@ -109,7 +109,7 @@ else:
def recv(self, size): def recv(self, size):
while True: while True:
try: try:
data = os_read(self.fileno(), size) data = _read(self.fileno(), size)
except (IOError, OSError): except (IOError, OSError):
code = sys.exc_info()[1].args[0] code = sys.exc_info()[1].args[0]
if code in ignored_errors: if code in ignored_errors:
......
...@@ -22,9 +22,9 @@ except ImportError: ...@@ -22,9 +22,9 @@ except ImportError:
__implements__ = ['read', 'write', 'fork'] __implements__ = ['read', 'write', 'fork']
__all__ = __implements__ __all__ = __implements__
os_read = os.read _read = os.read
os_write = os.write _write = os.write
os_fork = os.fork _fork = os.fork
ignored_errors = [EAGAIN, errno.EINTR] ignored_errors = [EAGAIN, errno.EINTR]
...@@ -58,7 +58,7 @@ def posix_read(fd, n): ...@@ -58,7 +58,7 @@ def posix_read(fd, n):
if not flags & os.O_NONBLOCK: if not flags & os.O_NONBLOCK:
_map_errors(fcntl.fcntl, fd, fcntl.F_SETFL, flags|os.O_NONBLOCK) _map_errors(fcntl.fcntl, fd, fcntl.F_SETFL, flags|os.O_NONBLOCK)
try: try:
return os_read(fd, n) return _read(fd, n)
except OSError, e: except OSError, e:
if e.errno not in ignored_errors: if e.errno not in ignored_errors:
raise raise
...@@ -86,7 +86,7 @@ def posix_write(fd, buf): ...@@ -86,7 +86,7 @@ def posix_write(fd, buf):
if not flags & os.O_NONBLOCK: if not flags & os.O_NONBLOCK:
_map_errors(fcntl.fcntl, fd, fcntl.F_SETFL, flags|os.O_NONBLOCK) _map_errors(fcntl.fcntl, fd, fcntl.F_SETFL, flags|os.O_NONBLOCK)
try: try:
return os_write(fd, buf) return _write(fd, buf)
except OSError, e: except OSError, e:
if e.errno not in ignored_errors: if e.errno not in ignored_errors:
raise raise
...@@ -105,13 +105,13 @@ def threadpool_read(fd, n): ...@@ -105,13 +105,13 @@ def threadpool_read(fd, n):
"""Read up to `n` bytes from file descriptor `fd`. Return a string """Read up to `n` bytes from file descriptor `fd`. Return a string
containing the bytes read. If end-of-file is reached, an empty string containing the bytes read. If end-of-file is reached, an empty string
is returned.""" is returned."""
return get_hub().threadpool.apply(os_read, (fd, n)) return get_hub().threadpool.apply(_read, (fd, n))
def threadpool_write(fd, buf): def threadpool_write(fd, buf):
"""Write bytes from buffer `buf` to file descriptor `fd`. Return the """Write bytes from buffer `buf` to file descriptor `fd`. Return the
number of bytes written.""" number of bytes written."""
return get_hub().threadpool.apply(os_write, (fd, buf)) return get_hub().threadpool.apply(_write, (fd, buf))
if fcntl is None: if fcntl is None:
...@@ -125,7 +125,7 @@ else: ...@@ -125,7 +125,7 @@ else:
if hasattr(os, 'fork'): if hasattr(os, 'fork'):
def fork(): def fork():
result = os_fork() result = _fork()
if not result: if not result:
reinit() reinit()
return result return result
......
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