|
View:
New views
6 Messages
—
Rating Filter:
Alert me
|
|
|
How to do a callback sort of thing with pyAmfIs there a well known pattern for handling a case where a client should
get notified when the state of a server/remote object changes? I figure I can make the client make a remote call that blocks on a condition variable in my server and wake it up when the data changes but that means a thread per client and I don't like how that scales? Any pointers or guidance greatly appreciated. Mike (wishing python had continuations) _______________________________________________ PyAMF users mailing list - users@... http://lists.pyamf.org/mailman/listinfo/users |
|
|
|
|
|
Re: How to do a callback sort of thing with pyAmfThanks Andrew. That gets me pointed in the right direction. I've not
used Twisted but wanted to look at it so sounds like the time is right. Again, thanks for the help and the very quick response! Mike On Tue, 2009-05-12 at 18:24 +0000, Andrew Francis wrote: > Hi Mike: > > --- On Tue, 5/12/09, Mike Dickson <mike.dickson@...> wrote: > > > > Is there a well known pattern for handling a case where a client > > should get notified when the state of a server/remote object > > changes? I figure I can make the client make a remote call that blocks > > on a condition variable in my server and wake it up when the data changes > > but that means a thread per client and I don't like how that > > scales? > > Since I left my last gig, I haven't played with PyAMF. So here goes.... > > Like the Observer design pattern? > > If I understand you correctly, perhaps you can poll the remote site with task.loopingCall(). If the loopingCall function detects a change, > it can create a Deferred and start the processing by doing a callback. > This way you are not creating threads. > > pseudo code > > """ > my application logic is in here > """ > def doSomething(result): > ..... > > """ > your polling/state change logic is here > > """ > > def poll(): > state = yield client.getPage(...) #short-hand, an inlineCallback > if state != oldState: > oldState = state > deferred = defer.Deferred().addCallback(doSomething) > deferred.callback(result) # start the processing right away > > in startup code > > task = tasking.loopingCall(poll) > task.start(.01) > > > > Mike (wishing python had continuations) > > You could use Stackless Python. About a year ago, I posted examples of how to use PyAMF with Stackless. Shameless plug: I also presented a talk at Pycon 2008 "Adventures in Stackless Python Twisted Integration." > > Cheers, > Andrew > _______________________________________________ PyAMF users mailing list - users@... http://lists.pyamf.org/mailman/listinfo/users |
|
|
Re: How to do a callback sort of thing with pyAmfOn 12 May 2009, at 19:24, Andrew Francis wrote: >> [snip] > > You could use Stackless Python. About a year ago, I posted examples > of how to use PyAMF with Stackless. Shameless plug: I also presented > a talk at Pycon 2008 "Adventures in Stackless Python Twisted > Integration." I believe that example was posted on our wiki, see http://pyamf.org/wiki/StacklessPythonTwisted Cheers, Thijs _______________________________________________ PyAMF users mailing list - users@... http://lists.pyamf.org/mailman/listinfo/users |
|
|
|
|
|
Re: How to do a callback sort of thing with pyAmfThanks Andrew, looking forward to any examples you can provide. Feel free to open tickets for them so we can integrate them into the documentation/examples etc.
Cheers, Thijs On 14 May 2009, at 20:01, Andrew Francis wrote:
_______________________________________________ PyAMF users mailing list - users@... http://lists.pyamf.org/mailman/listinfo/users |
| Free embeddable forum powered by Nabble | Forum Help |