Well, as you've seen already, there used to be twisted integration that was
removed, due to the fact rpyc is incompatible with the reactor model. It's
not something you can fix without breaking rpyc completely. For instance,
doing "foo.bar" where foo is an rpyc netref means getattr does IO, thus
ought to take place via twisted (or any reactor). Doing IO yourself breaks
the assumptions on which reactors are based, being, they manage all IO.

The only plausible compromise is using coroutines, a la microactor, cogen
or multitask, and writing your code like so:

@coroutine   # or twisted's @inlineCallbacks
def do_something(remobj, val):
    some_method = yield remobj.some_method   # spam.bacon returns a
deferred computation, not a result
    res = yield some_method(val)

or the unreadable ``yield (yield remobj.some_method)(val)``

etc. etc.

there's nothing to do -- either you're transparent, and then you have to be
sync, or you're location-aware which allows you to be async but requires
special treatment everywhere

-----------------------------------------------------------------

*Tomer Filiba*
tomerfiliba.com     <http://www.facebook.com/tomerfiliba>
<http://il.linkedin.com/in/tomerfiliba>



On Fri, Oct 19, 2012 at 12:44 AM, Oliver Drake <[email protected]> wrote:

> Hey Tomer,
> I've been looking at rewriting some of our test tools at work using
> asynchronous frameworks as we need to be able to generate many simultaneous
> UDP/RTP voice streams in order to load up our units under test. However
> we've got existing synchronous test scripts and we generally like to write
> test code synchronously. So I thought RPyC (or RPC in general) would be a
> nice way to leverage the power of asynchronous programming for doing the
> realtime UDP stuff from synchronous test scripts (see attached image). I've
> been playing around with twisted, gevent, asyncore and diesel. I've settled
> on twisted for now as it comes with a bunch of stuff including 
> LoopingCall<http://twistedmatrix.com/documents/8.1.0/api/twisted.internet.task.LoopingCall.html>
>  and
> a Multicast UDP implementation.
> I did some googling and couldn't find any existing server side
> twisted/rpyc implementations (I did scan through old rpyc commits and saw
> there used to be a client side twisted protocol?) so I decided to write my
> own (inspired by the twisted_integration.py code). It's pretty rough at the
> moment, basically glueing existing rpyc code into twisted :p The
> performance of this code running in twisted is a bit worse than running
> rpyc synchronously using the servers that come with rpyc... Not that
> performance is that critical for us, but I'm taking that as a clue that
> there's potentially a more efficient and nicer approach.
> The code can be found here: https://github.com/oliverdrake/twisted-rpyc,
> if you've got time any pointers you could give me on improving this (or if
> you know of existing implementations) that would be great,
> Thanks,
> Oliver
>
>
>

Reply via email to