[Twisted-Python] Deferring 201 status code

2015-06-23 Thread Vikas Kumar
Hi,

My controller code first updates DB and then sends out 201 status code
indicating it is done updating in DB.
Issue is somebody waiting to fetch this update from DB will not work
immediately because DB update takes some time(approximately 0.5 second) to
come into effect.

Is there a way I can control/defer sending out 201?
Any sample code/link will be appreciated.

Regards
Vikas
___
Twisted-Python mailing list
Twisted-Python@twistedmatrix.com
http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python


[Twisted-Python] Return only when value/handle is available

2014-09-03 Thread vikas kumar

Hi,

I am little new to twisted.
I've a function(get_handle) which returns a handle.

But get_handle() may throw an exception(SystemDelayException) because of 
some delay in system.
My requirement is : When I get SystemDelayException re-attempt 
get_handle() and return only when handle is available. How do I use 
deferred/reactor in this scenario?


try:
handle = yield self.get_handle()
except SystemDelayException:
// code to re-attempt get_handle and return only when handle is 
available


Regards
Vikas


___
Twisted-Python mailing list
Twisted-Python@twistedmatrix.com
http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python


Re: [Twisted-Python] Return only when value/handle is available

2014-09-03 Thread vikas kumar

Hi Jonas,

This is nice.
But still we are retrying it repeatedly at regular interval(10). Can't 
we get the notified asynchronously as and when handle is available.


Regards
Vikas

On 9/3/2014 6:10 PM, Jonas Brunsgaard wrote:

I would fiddle around with something like this.

from twisted.internet.defer import inlineCallbacks, returnValue, Deferred
from twisted.internet import reactor


@inlineCallbacks
def foo(self, retries=10, interval=10):
while True:
try:
returnValue((yield self.get_handle()))
except SystemDelayException as e:
if retries > 0:
retries -= 1
d = Deferred()
reactor.callLater(interval, d.callback, None)
yield d
else:
raise e

On Wed, Sep 3, 2014 at 1:32 PM, vikas kumar <mailto:vikas.c.ku...@oracle.com>> wrote:


Hi,

I am little new to twisted.
I've a function(get_handle) which returns a handle.

But get_handle() may throw an exception(SystemDelayException)
because of some delay in system.
My requirement is : When I get SystemDelayException re-attempt
get_handle() and return only when handle is available. How do I
use deferred/reactor in this scenario?

try:
handle = yield self.get_handle()
except SystemDelayException:
// code to re-attempt get_handle and return only when handle
is available

Regards
Vikas


___
Twisted-Python mailing list
Twisted-Python@twistedmatrix.com
<mailto:Twisted-Python@twistedmatrix.com>
http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python




___
Twisted-Python mailing list
Twisted-Python@twistedmatrix.com
http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python


___
Twisted-Python mailing list
Twisted-Python@twistedmatrix.com
http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python


[Twisted-Python] Manhole info needed

2014-11-10 Thread Vikas Kumar
Hi,

Can somebody tell me what is the need of manhole in twisted? Specially I've
seen them in files like tap.py (twisted application process).

One usecase I've seen them is wrt ShellFactory classes:

manhole = ShellFactory()
manhole.setService(self)

internet.TCPServer(.config.dget('jsonapi.port') + 1,
manhole, interface='127.0.0.1').setServiceParent(self)

Could somebody please tell me what is being tried to achieve over here in
the above code?
___
Twisted-Python mailing list
Twisted-Python@twistedmatrix.com
http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python