mirror of
				https://github.com/python/cpython.git
				synced 2025-10-31 13:41:24 +00:00 
			
		
		
		
	Merge asyncio from 3.5
This commit is contained in:
		
						commit
						898ac56fc2
					
				
					 2 changed files with 97 additions and 11 deletions
				
			
		|  | @ -305,14 +305,20 @@ def __init__(self, loop, pipe, protocol, waiter=None, extra=None): | |||
|         self._loop = loop | ||||
|         self._pipe = pipe | ||||
|         self._fileno = pipe.fileno() | ||||
|         self._protocol = protocol | ||||
|         self._closing = False | ||||
| 
 | ||||
|         mode = os.fstat(self._fileno).st_mode | ||||
|         if not (stat.S_ISFIFO(mode) or | ||||
|                 stat.S_ISSOCK(mode) or | ||||
|                 stat.S_ISCHR(mode)): | ||||
|             self._pipe = None | ||||
|             self._fileno = None | ||||
|             self._protocol = None | ||||
|             raise ValueError("Pipe transport is for pipes/sockets only.") | ||||
| 
 | ||||
|         _set_nonblocking(self._fileno) | ||||
|         self._protocol = protocol | ||||
|         self._closing = False | ||||
| 
 | ||||
|         self._loop.call_soon(self._protocol.connection_made, self) | ||||
|         # only start reading when connection_made() has been called | ||||
|         self._loop.call_soon(self._loop.add_reader, | ||||
|  | @ -422,25 +428,30 @@ def __init__(self, loop, pipe, protocol, waiter=None, extra=None): | |||
|         self._extra['pipe'] = pipe | ||||
|         self._pipe = pipe | ||||
|         self._fileno = pipe.fileno() | ||||
|         mode = os.fstat(self._fileno).st_mode | ||||
|         is_socket = stat.S_ISSOCK(mode) | ||||
|         if not (is_socket or | ||||
|                 stat.S_ISFIFO(mode) or | ||||
|                 stat.S_ISCHR(mode)): | ||||
|             raise ValueError("Pipe transport is only for " | ||||
|                              "pipes, sockets and character devices") | ||||
|         _set_nonblocking(self._fileno) | ||||
|         self._protocol = protocol | ||||
|         self._buffer = [] | ||||
|         self._conn_lost = 0 | ||||
|         self._closing = False  # Set when close() or write_eof() called. | ||||
| 
 | ||||
|         mode = os.fstat(self._fileno).st_mode | ||||
|         is_char = stat.S_ISCHR(mode) | ||||
|         is_fifo = stat.S_ISFIFO(mode) | ||||
|         is_socket = stat.S_ISSOCK(mode) | ||||
|         if not (is_char or is_fifo or is_socket): | ||||
|             self._pipe = None | ||||
|             self._fileno = None | ||||
|             self._protocol = None | ||||
|             raise ValueError("Pipe transport is only for " | ||||
|                              "pipes, sockets and character devices") | ||||
| 
 | ||||
|         _set_nonblocking(self._fileno) | ||||
| 
 | ||||
|         self._loop.call_soon(self._protocol.connection_made, self) | ||||
| 
 | ||||
|         # On AIX, the reader trick (to be notified when the read end of the | ||||
|         # socket is closed) only works for sockets. On other platforms it | ||||
|         # works for pipes and sockets. (Exception: OS X 10.4?  Issue #19294.) | ||||
|         if is_socket or not sys.platform.startswith("aix"): | ||||
|         if is_socket or (is_fifo and not sys.platform.startswith("aix")): | ||||
|             # only start reading when connection_made() has been called | ||||
|             self._loop.call_soon(self._loop.add_reader, | ||||
|                                  self._fileno, self._read_ready) | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Guido van Rossum
						Guido van Rossum