Open tcalmant opened 5 years ago
First try to implement an asyncio server is a success, using aiohttp
as the underlying HTTP server.
Here are the tasks to implement the asynchronous server:
aiohttp
based on that asynchronous JSON-RPC handlerFor an asynchronous client:
ServerProxy
class from XML-RPC is still the way to goServerProxy
API with an aiohttp
clientServerProxy
in the asynchronous versionThe first version of the asynchronous request handler has been pushed on the protocol_extract
branch.
A draft of documentation have also been pushed, with a snippet to start the server with aiohttp.
And I finally found the time to make an aiohttp
version of ServerProxy
(called AsyncServerProxy
).
It is available on the protocol_extract
branch.
The usage is pretty straightforward: you just need to use await
in front of all calls to the server.
The dependency on aiohttp
is somehow limited, as I mimic the Transport
model of the xmlrpclib
model. Maybe I'll put the aiohttp
specific code in another module in order to avoid a hard dependency on this library.
Documentation and unit tests are still to be written. Please comment with to this issue if you try the asynchronous mode and find good or bad.
Protocol unit tests from the synchronous client and server are now also applied on their asynchronous versions.
Next steps will be:
aiohttp
specific parts to a sub-package, to allow implementations based on other libraries without requiring the installation of aiohttp
aiohttp
-based server in said sub-package (currently only available in the tests)aiohttp
specific code has been moved to a new impl
subpackage. It should now be possible to create a new provider with another library (I don't know a lot of equivalents).
I've also added some type hints and potentially fixed a bug in the class converter (when copying the LocalClasses
dictionary)
Documentation is still a draft, available as the protocol_extract
version.
It would be interesting to implement an
asyncio
-based version of the library, as it undeniably increases performances in most I/O cases.This would require a big refactoring of the project, in order to share as most code as possible between the sync & async versions of the transport and protocol layers.
It is necessary to decide if the project will depend on a third-party library to handle this or if it will use the Python 3.4+ API & syntax. Note: the library has to stay compatible with Python 2 (at least for some years), which means all of the Python 3 syntax would be in a specific module, loaded when possible.
You can vote for or against this proposal.