Re: [Twisted-Python] Unhandled Deferred Error

2010-08-26 Thread Paul Goins
Hello Shwetanka, Just looking at this traceback, the error looks like it was raised at starpy/fastagi.py:145, and the Deferred in question had its callback called at starpy/fastagi.py:120. Both are starpy code. I'd suggest asking the starpy people. This traceback makes it look like the error

Re: [Twisted-Python] help with Deferreds

2010-08-26 Thread Sergey Magafurov
Yes, I was expecting you to wrap item.obsolete() and renew(data) in try/except, as needed. If you want a clean but slightly slower way to do that, how about something like: def getCachedResult(cache, key): def release(result, item): item.release() return result d

Re: [Twisted-Python] help with Deferreds

2010-08-26 Thread Sergey Magafurov
If you don't like that construct, perhaps this one is nicer: from twisted.internet.defer import maybeDeferred def getCachedResult(cache, key): def _readItem(item): if item.obsolete(): return None return item.read() def _gotResult(item): def _release

Re: [Twisted-Python] help with Deferreds

2010-08-26 Thread Terry Jones
Hi Sergey > def checkObsolete(item): > if item.obsolete(): > return None > else: > d = item.read() > d.addBoth(release, item) > d.addCallback(renew) > return d > > d = cache.open(key) > d.addCallbacks

Re: [Twisted-Python] help with Deferreds

2010-08-26 Thread Tristan Seligmann
On Thu, Aug 26, 2010 at 12:23 PM, Sergey Magafurov wrote: > I ask this question because I am confusing with this ugly slice of code: > > try: >     ... > except: >     item.release() >     raise If you don't like that construct, perhaps this one is nicer: from twisted.internet.defer import maybe

Re: [Twisted-Python] help with Deferreds

2010-08-26 Thread Sergey Magafurov
> def getCachedResult(cache, key): > > def release(result, item): > item.release() > return result > > def renew(data): > return renew(data) > > def notFound(fail): > fail.trap(NotFound) > > def checkObsolete(item): > if item.obsolet

Re: [Twisted-Python] help with Deferreds

2010-08-26 Thread Sergey Magafurov
> I would probably write it something like this: > > def getCachedResult(cache, key): > def _gotResult(item): > try: > if item.obsolete(): > return None > d = item.read() > d.addCallback(lambda data: renew(data)) > exce

Re: [Twisted-Python] help with Deferreds

2010-08-26 Thread Terry Jones
Hi Sergey > How to rewrite this regular function with Deferred-style? Something like the below (untested) will do the job. You'd have to make sure that cache.open returned a deferred that fails with NotFound in case things don't work out. It would be simpler to translate your code using inlineC

[Twisted-Python] Twisted and SOAP

2010-08-26 Thread Einar S . Idsø
Hi, What is currently the recommended option for letting Twisted applications communicate with SOAP services? Cheers, Einar ___ Twisted-Python mailing list Twisted-Python@twistedmatrix.com http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-pytho

Re: [Twisted-Python] help with Deferreds

2010-08-26 Thread Tristan Seligmann
On Thu, Aug 26, 2010 at 11:47 AM, Sergey Magafurov wrote: > How to rewrite this regular function with Deferred-style? > Conditions: > 1. 'cache.open' and 'item.read' become deffered > 2. 'item.obsolete()' and 'renew(data)' are not deferred I would probably write it something like this: def getC

[Twisted-Python] help with Deferreds

2010-08-26 Thread Sergey Magafurov
How to rewrite this regular function with Deferred-style? def getCachedResult(cache, key): try: item = cache.open(key) except NotFound: return None try: if item.obsolete(): return None data = item.read() finally: item.r

[Twisted-Python] Unhandled Deferred Error

2010-08-26 Thread shwetanka srivastava
Hi I'm using twisted api with starpy to make a conference call. After a successful call this error is logged in my log file ERROR:twsited:Unhandled error in Deferred: ERROR:twsited:Unhandled Error Traceback (most recent call last): File "/usr/lib/python2.6/dist-packages/twisted/protocols/basic.