Add support for asynchronous operation
Closed this issue · 3 comments
I doubt it's possible since there's so many async library (tornado, twisted, tasklet...).
However evelink could delegate the I/O operations to those libraries and keep doing the parsing... Maybe something like that:
https://github.com/dinoboff/evelink/blob/master/tests/test_appengine.py#L165
In that example, AppEngineAPI has a "get_async" method with return a Future object (the yield used in the tasklet allows other concurrent tasklet to run while the I/O operation complete and automatically return the result out of the Future object); then the result is given to eve.EVE.character_info_from_id via the extra argument "api_result".
I don't think I'm likely to implement this myself, but I'd be willing to consider pull requests and/or discuss potential means.
The #147 pull request is ready for review. Basically it does:
- adds async methods to appengine api and cache classes.
- adds an
api_result
argument to all api wrappers methods that they will use instead of querying the api server themselves when it's given. - adds a decorator to check if
api_result
is given and query the server when it's not. It also attached details about the request path and parameter to the methods. - adds a decorator to create automatically async version of those methods.