Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support async use-cases #127

Open
non-Jedi opened this issue May 5, 2017 · 3 comments
Open

Support async use-cases #127

non-Jedi opened this issue May 5, 2017 · 3 comments

Comments

@non-Jedi
Copy link
Collaborator

non-Jedi commented May 5, 2017

Since we're supporting both python2 and python3, our async options are very limited. I think we have to either use gevent, use threading, or maybe we can use something from the twisted stack?

Personally, I'd really like to just drop support for python2 (it is the way the ecosystem is moving anyway), and use either the 3.4 syntax of @asyncio.coroutine and yield from or 3.5+ of async def and await. It would give us much more semantic code. Maybe the right answer is just a community-maintained async fork for python 3.4+.

Issue created to separate out discussion from #126.

@pik
Copy link
Contributor

pik commented May 6, 2017

Absolutely not. Async will make the REPL experience significantly worse, python3 async API has been constantly changing, python2 has no async equivalent to the python3 in the stdlib (you'd have to use gevent or something) - finally again, this is totally unnecessary - I use the sdk at the moment to run synchronous tests / REPL and there is no cause for extra complexity.

If you are building something that needs extra complexity, you should wrap the sdk in whatever async / threading paradigm that you need.

@non-Jedi
Copy link
Collaborator Author

non-Jedi commented May 6, 2017

You're right. I hadn't fully considered the implications of making it async. It would make usage of the sdk more difficult for >50% of use-cases. As an aside, I believe that python3's async api hasn't changed since 3.5, and it's considered stable in 3.6, but that's beside the point.

The reason I opened this issue is that it would be nice to include a lot of the architecture needed for building an event-driven app in one place. One of the more obvious examples would be queuing requests as I believe is done in the JS sdk. Maybe there just needs to be another package wrapping this one providing that async architecture; I don't know.

At the very least, to support async use-cases, we need to get rid of the while loop inside of _send or make it explicit in the documentation that the _send method must be overridden to support async.

@non-Jedi non-Jedi changed the title Make sdk async by default Support async use-cases May 6, 2017
@pik
Copy link
Contributor

pik commented May 6, 2017

At the very least, to support async use-cases, we need to get rid of the while loop inside of _send or make it explicit in the documentation that the _send method must be overridden to support async.

I tend to agree that we shouldn't be defining re-try paradigms in the sdk (#62 (comment)); especially if you are hitting api-request limits than probably blocking with sleep isn't what you want anyways.

As for patching _send I think you may have to do that anyways so that you can use a e.g. aiohttp or another library which provides http methods that you can yield_from.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants