python-meteor icon indicating copy to clipboard operation
python-meteor copied to clipboard

Synchronous method calls

Open ccorcos opened this issue 10 years ago • 7 comments

Hey, I just created a package syncify to wrap client method calls so they behave synchronously.

call = syncify(client.call)
error, result = call('method', [argument])

That way you dont have to do the while True hack when scripting.

ccorcos avatar Nov 18 '14 05:11 ccorcos

I checked out your library and the implementation looks clean (34 LOC - nice work!). I don't have time at the moment to add parity functions for all the async methods. But I'm going to keep this open as a feature request.

hharnisc avatar Nov 18 '14 16:11 hharnisc

One more thing, have you tested your package with python 3.x? (not saying that python-meteor does but mostly thinking ahead)

hharnisc avatar Nov 18 '14 16:11 hharnisc

I have yet to touch python 3, haha. I suppose I probably should at some point, but just about every library is written for 2 so I'm not sure when I'm going to transition...

ccorcos avatar Nov 18 '14 17:11 ccorcos

Wouldn't this be better implemented using generators?

mitar avatar Dec 10 '14 22:12 mitar

I've head about generators but I don't know how they are used for this kind of stuff. I'd be happy to hear your idea

ccorcos avatar Dec 12 '14 09:12 ccorcos

After more thought I do not think it is possible to do it with just generators. But probably a better approach to the whole thing would be using greenlets, a coroutine approach, similar to node-fibers. And then there is geven-websocket. So we could get a blocking-looking interface similar to node-fibers, but have asynchronous behavior in the background.

mitar avatar Dec 18 '14 22:12 mitar

Or just use Tornado, maybe :+1:

gabrielhpugliese avatar Jun 16 '15 01:06 gabrielhpugliese