Python Manual User Manual

Page of 124
Lack of Response
63
Lack of Response
When you send a request, there is no gaurantee that the remote service agent hasn’t been destroyed
even before it receives your request. If a remote service agent delays sending an immediate response
to your request, the problem might also arise that the remote service agent is destroyed before it com-
pletes the response. Finally, an intermediate process relaying your request might be shutdown or crash
meaning either the request or response is lost.
In order to handle these situations, when the "
processFailure()
" member function is used to reg-
ister interest in the failure of a request, it will automatically setup a subscription on the existance of the
remote service agent against which the request has been made. In the event that the remote service
agent becomes unavailable before a response is received, an application error will be returned as a fail-
ure to provide notification of this occuring.
class Client(netsvc.Service):
def __init__(self,name):
netsvc.Service.__init__(self,"","")
service = self.serviceEndPoint("SMS")
if service:
id = service.uptime()
self.processResponse(self.uptimeResponse,id)
self.processFailure(self.uptimeFailure,id)
def uptimeResponse(self,result):
print result
def uptimeFailure(self,id,error,description,origin,details):
if origin == "netsvc" and error == netsvc.SERVER_APPLICATION_ERROR:
# request has failed, possibly because no response was received
Note that the "
monitorResponse()
" member function which has been made deprecated as of OSE
7.0pl5, does not setup a subscription to the existance of the remote service agent. Thus, if you are using
this older member function to catch the failure of a request, you will not get any failure notification in
these circumstances.
Although the "
processFailure()
" member function will ensure that a failure is returned if no re-
sponse is received prior to the remote service agent becoming unavailable, programming errors or ex-
ternal communications failures in code associated with the remote service agent might still result in no
response being received where the remote service agent still exists. If this is an issue and you also want
to implement a timeout whereby if no response has been received within a certain period of time, a
timeout value can be supplied when you call the "
processFailure()
" member function.
class Client(netsvc.Service):
def __init__(self,name):
netsvc.Service.__init__(self,"","")
service = self.serviceEndPoint("SMS")
if service:
id = service.uptime()
self.processResponse(self.uptimeResponse,id)