Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(6)

Delta Between Two Patch Sets: Lib/asyncio/base_events.py

Issue 27906: Socket accept exhaustion during high TCP traffic
Left Patch Set: Created 3 years, 5 months ago
Right Patch Set: Created 3 years, 5 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « no previous file | Lib/asyncio/selector_events.py » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
(Both sides are equal)
1 """Base implementation of event loop. 1 """Base implementation of event loop.
2 2
3 The event loop can be broken up into a multiplexer (the part 3 The event loop can be broken up into a multiplexer (the part
4 responsible for notifying us of I/O events) and the event loop proper, 4 responsible for notifying us of I/O events) and the event loop proper,
5 which wraps a multiplexer with functionality for scheduling callbacks, 5 which wraps a multiplexer with functionality for scheduling callbacks,
6 immediately or at a given time in the future. 6 immediately or at a given time in the future.
7 7
8 Whenever a public API takes a callback, subsequent positional 8 Whenever a public API takes a callback, subsequent positional
9 arguments will be passed to the callback if/when it is called. This 9 arguments will be passed to the callback if/when it is called. This
10 avoids the proliferation of trivial lambdas implementing closures. 10 avoids the proliferation of trivial lambdas implementing closures.
(...skipping 1051 matching lines...) Expand 10 before | Expand all | Expand 10 after
1062 raise ValueError("bufsize must be 0") 1062 raise ValueError("bufsize must be 0")
1063 protocol = protocol_factory() 1063 protocol = protocol_factory()
1064 if self._debug: 1064 if self._debug:
1065 # don't log parameters: they may contain sensitive information 1065 # don't log parameters: they may contain sensitive information
1066 # (password) and may be too long 1066 # (password) and may be too long
1067 debug_log = 'run shell command %r' % cmd 1067 debug_log = 'run shell command %r' % cmd
1068 self._log_subprocess(debug_log, stdin, stdout, stderr) 1068 self._log_subprocess(debug_log, stdin, stdout, stderr)
1069 transport = yield from self._make_subprocess_transport( 1069 transport = yield from self._make_subprocess_transport(
1070 protocol, cmd, True, stdin, stdout, stderr, bufsize, **kwargs) 1070 protocol, cmd, True, stdin, stdout, stderr, bufsize, **kwargs)
1071 if self._debug: 1071 if self._debug:
1072 logger.info('%s: %r' % (debug_log, transport)) 1072 logger.info('%s: %r', debug_log, transport)
1073 return transport, protocol 1073 return transport, protocol
1074 1074
1075 @coroutine 1075 @coroutine
1076 def subprocess_exec(self, protocol_factory, program, *args, 1076 def subprocess_exec(self, protocol_factory, program, *args,
1077 stdin=subprocess.PIPE, stdout=subprocess.PIPE, 1077 stdin=subprocess.PIPE, stdout=subprocess.PIPE,
1078 stderr=subprocess.PIPE, universal_newlines=False, 1078 stderr=subprocess.PIPE, universal_newlines=False,
1079 shell=False, bufsize=0, **kwargs): 1079 shell=False, bufsize=0, **kwargs):
1080 if universal_newlines: 1080 if universal_newlines:
1081 raise ValueError("universal_newlines must be False") 1081 raise ValueError("universal_newlines must be False")
1082 if shell: 1082 if shell:
1083 raise ValueError("shell must be False") 1083 raise ValueError("shell must be False")
1084 if bufsize != 0: 1084 if bufsize != 0:
1085 raise ValueError("bufsize must be 0") 1085 raise ValueError("bufsize must be 0")
1086 popen_args = (program,) + args 1086 popen_args = (program,) + args
1087 for arg in popen_args: 1087 for arg in popen_args:
1088 if not isinstance(arg, (str, bytes)): 1088 if not isinstance(arg, (str, bytes)):
1089 raise TypeError("program arguments must be " 1089 raise TypeError("program arguments must be "
1090 "a bytes or text string, not %s" 1090 "a bytes or text string, not %s"
1091 % type(arg).__name__) 1091 % type(arg).__name__)
1092 protocol = protocol_factory() 1092 protocol = protocol_factory()
1093 if self._debug: 1093 if self._debug:
1094 # don't log parameters: they may contain sensitive information 1094 # don't log parameters: they may contain sensitive information
1095 # (password) and may be too long 1095 # (password) and may be too long
1096 debug_log = 'execute program %r' % program 1096 debug_log = 'execute program %r' % program
1097 self._log_subprocess(debug_log, stdin, stdout, stderr) 1097 self._log_subprocess(debug_log, stdin, stdout, stderr)
1098 transport = yield from self._make_subprocess_transport( 1098 transport = yield from self._make_subprocess_transport(
1099 protocol, popen_args, False, stdin, stdout, stderr, 1099 protocol, popen_args, False, stdin, stdout, stderr,
1100 bufsize, **kwargs) 1100 bufsize, **kwargs)
1101 if self._debug: 1101 if self._debug:
1102 logger.info('%s: %r' % (debug_log, transport)) 1102 logger.info('%s: %r', debug_log, transport)
1103 return transport, protocol 1103 return transport, protocol
1104 1104
1105 def get_exception_handler(self): 1105 def get_exception_handler(self):
1106 """Return an exception handler, or None if the default one is in use. 1106 """Return an exception handler, or None if the default one is in use.
1107 """ 1107 """
1108 return self._exception_handler 1108 return self._exception_handler
1109 1109
1110 def set_exception_handler(self, handler): 1110 def set_exception_handler(self, handler):
1111 """Set handler as the new event loop exception handler. 1111 """Set handler as the new event loop exception handler.
1112 1112
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
1367 self._coroutine_wrapper_set = False 1367 self._coroutine_wrapper_set = False
1368 1368
1369 def get_debug(self): 1369 def get_debug(self):
1370 return self._debug 1370 return self._debug
1371 1371
1372 def set_debug(self, enabled): 1372 def set_debug(self, enabled):
1373 self._debug = enabled 1373 self._debug = enabled
1374 1374
1375 if self.is_running(): 1375 if self.is_running():
1376 self._set_coroutine_wrapper(enabled) 1376 self._set_coroutine_wrapper(enabled)
LEFTRIGHT

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+