Style & documentation tweaks from review
This commit is contained in:
		@@ -197,6 +197,7 @@ latex_documents = [
 | 
				
			|||||||
#latex_use_modindex = True
 | 
					#latex_use_modindex = True
 | 
				
			||||||
 | 
					
 | 
				
			||||||
intersphinx_mapping = {
 | 
					intersphinx_mapping = {
 | 
				
			||||||
    'python': ('https://docs.python.org/2', None),
 | 
					    'py2': ('https://docs.python.org/2', None),
 | 
				
			||||||
 | 
					    'py3': ('https://docs.python.org/3', None),
 | 
				
			||||||
    'twisted': ('https://twistedmatrix.com/documents/current/api/', None),
 | 
					    'twisted': ('https://twistedmatrix.com/documents/current/api/', None),
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -11,8 +11,8 @@ class DeferredNotFired(Exception):
 | 
				
			|||||||
    """Raised when we extract a result from a Deferred that's not fired yet."""
 | 
					    """Raised when we extract a result from a Deferred that's not fired yet."""
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def __init__(self, deferred):
 | 
					    def __init__(self, deferred):
 | 
				
			||||||
        super(DeferredNotFired, self).__init__(
 | 
					        msg = "%r has not fired yet." % (deferred,)
 | 
				
			||||||
            "%r has not fired yet." % (deferred,))
 | 
					        super(DeferredNotFired, self).__init__(msg)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def extract_result(deferred):
 | 
					def extract_result(deferred):
 | 
				
			||||||
@@ -24,8 +24,10 @@ def extract_result(deferred):
 | 
				
			|||||||
    case, you can use this function to convert the result back into the usual
 | 
					    case, you can use this function to convert the result back into the usual
 | 
				
			||||||
    form for a synchronous API, i.e. the result itself or a raised exception.
 | 
					    form for a synchronous API, i.e. the result itself or a raised exception.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    It would be very bad form to use this as some way of checking if a
 | 
					    As a rule, this function should not be used when operating with
 | 
				
			||||||
    Deferred has fired.
 | 
					    asynchronous Deferreds (i.e. for normal use of Deferreds in application
 | 
				
			||||||
 | 
					    code). In those cases, it is better to add callbacks and errbacks as
 | 
				
			||||||
 | 
					    needed.
 | 
				
			||||||
    """
 | 
					    """
 | 
				
			||||||
    failures = []
 | 
					    failures = []
 | 
				
			||||||
    successes = []
 | 
					    successes = []
 | 
				
			||||||
@@ -42,10 +44,10 @@ class ImpossibleDeferredError(Exception):
 | 
				
			|||||||
    """Raised if a Deferred somehow triggers both a success and a failure."""
 | 
					    """Raised if a Deferred somehow triggers both a success and a failure."""
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def __init__(self, deferred, successes, failures):
 | 
					    def __init__(self, deferred, successes, failures):
 | 
				
			||||||
 | 
					        msg = ('Impossible condition on %r, got both success (%r) and '
 | 
				
			||||||
 | 
					               'failure (%r)')
 | 
				
			||||||
        super(ImpossibleDeferredError, self).__init__(
 | 
					        super(ImpossibleDeferredError, self).__init__(
 | 
				
			||||||
            'Impossible condition on {}, got both success ({}) and '
 | 
					            msg % (deferred, successes, failures))
 | 
				
			||||||
            'failure ({})'.format(deferred, successes, failures)
 | 
					 | 
				
			||||||
        )
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def on_deferred_result(deferred, on_success, on_failure, on_no_result):
 | 
					def on_deferred_result(deferred, on_success, on_failure, on_no_result):
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -6,12 +6,13 @@ A "synchronous" Deferred is one that does not need the reactor or any other
 | 
				
			|||||||
asynchronous process in order to fire.
 | 
					asynchronous process in order to fire.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Normal application code can't know when a Deferred is going to fire, because
 | 
					Normal application code can't know when a Deferred is going to fire, because
 | 
				
			||||||
that is generally left up to the reactor. Well-written unit tests provide fake
 | 
					that is generally left up to the reactor. Unit tests can (and should!) provide
 | 
				
			||||||
reactors, or don't use the reactor at all, so that Deferreds fire
 | 
					fake reactors, or don't use the reactor at all, so that Deferreds fire
 | 
				
			||||||
synchronously.
 | 
					synchronously.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
These matchers allow you to make assertions about when and how Deferreds fire,
 | 
					These matchers allow you to make assertions about when and how Deferreds fire,
 | 
				
			||||||
and about what values they fire with.
 | 
					and about what values they fire with.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
"""
 | 
					"""
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# TODO: None of these are published yet. Decide where & how to make them
 | 
					# TODO: None of these are published yet. Decide where & how to make them
 | 
				
			||||||
@@ -160,9 +161,6 @@ class _Failed(object):
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# XXX: The Twisted name is failureResultOf. Do we want to use that name?
 | 
					# XXX: The Twisted name is failureResultOf. Do we want to use that name?
 | 
				
			||||||
#
 | 
					 | 
				
			||||||
# XXX: failureResultOf also takes an *args of expected exception types. Do we
 | 
					 | 
				
			||||||
# want to provide that?
 | 
					 | 
				
			||||||
def failed(matcher):
 | 
					def failed(matcher):
 | 
				
			||||||
    """Match a Deferred that has failed.
 | 
					    """Match a Deferred that has failed.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user