Bring serial API in line with async using requests-futures #37
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR rearranges the
SimpleContext
object to use aFuturesSession
for dispatching HTTP requests to a thread pool, rather than waiting for them to complete on the main thread. This brings the API for theSimpleContext
object in line with that of the asyncContext
object.TuberObject
methods are executed serially withoutawait
, and context methods return aFuture
whoseresult()
method returns the corresponding result from the server. Calling a context directly blocks until it responds, akin to theawait ctx()
API of the asyncContext
.To allow for asynchronous communication with several servers, the (non-blocking)
SimpleContext.send()
method returns aFuture
object whose (blocking)result()
method contains the fullrequests.Response
object as processed from the server. TheSimpleContext.receive()
method can then be used to block and return the results of each method executed on the server.