hharnisc / python-meteor

A meteor client for python
MIT License
157 stars 27 forks source link

Synchronous method calls #8

Open ccorcos opened 10 years ago

ccorcos commented 10 years ago

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.

hharnisc commented 9 years ago

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 commented 9 years ago

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

ccorcos commented 9 years ago

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...

mitar commented 9 years ago

Wouldn't this be better implemented using generators?

ccorcos commented 9 years ago

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

mitar commented 9 years ago

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.

gabrielhpugliese commented 9 years ago

Or just use Tornado, maybe :+1: