TornadoClient

TornadoClient is equivalent of the RPCClient but in HTTPS. Usage of TornadoClient is the same as RPCClient, you can instantiate TornadoClient with complete url (https://host:port/System/Component) or just “System/Component”. Like RPCClient you can use all method defined in your service, your call will be automatically transformed in RPC.

It also exposes the same interface for receiving file as the TransferClient.

Main changes:

  • KeepAliveLapse is removed, requests library manages it itself.

  • nbOfRetry (defined as private attribute) is removed, requests library manage it itself.

  • Underneath it uses HTTP POST protocol and JSON. See HTTPS Services with Tornado for details

Example:

from DIRAC.Core.Tornado.Client.TornadoClient import TornadoClient
myService = TornadoClient("Framework/MyService")
myService.doSomething() #Returns S_OK/S_ERROR
class DIRAC.Core.Tornado.Client.TornadoClient.TornadoClient(serviceName, **kwargs)

Bases: TornadoBaseClient

Client for calling tornado services Interface is based on RPCClient interface

KW_DELEGATED_DN = 'delegatedDN'
KW_DELEGATED_GROUP = 'delegatedGroup'
KW_EXTRA_CREDENTIALS = 'extraCredentials'
KW_IGNORE_GATEWAYS = 'ignoreGateways'
KW_KEEP_ALIVE_LAPSE = 'keepAliveLapse'
KW_PROXY_CHAIN = 'proxyChain'
KW_PROXY_LOCATION = 'proxyLocation'
KW_PROXY_STRING = 'proxyString'
KW_SETUP = 'setup'
KW_SKIP_CA_CHECK = 'skipCACheck'
KW_TIMEOUT = 'timeout'
KW_USE_ACCESS_TOKEN = 'useAccessToken'
KW_USE_CERTIFICATES = 'useCertificates'
KW_VO = 'VO'
VAL_EXTRA_CREDENTIALS_HOST = 'hosts'
__init__(serviceName, **kwargs)
Parameters:
  • serviceName – URL of the service (proper uri or just System/Component)

  • useCertificates – If set to True, use the server certificate

  • extraCredentials

  • timeout – Timeout of the call (default 600 s)

  • setup – Specify the Setup

  • VO – Specify the VO

  • delegatedDN – Not clear what it can be used for.

  • delegatedGroup – Not clear what it can be used for.

  • ignoreGateways – Ignore the DIRAC Gatways settings

  • proxyLocation – Specify the location of the proxy

  • proxyString – Specify the proxy string

  • proxyChain – Specify the proxy chain

  • skipCACheck – Do not check the CA

  • keepAliveLapse – Duration for keepAliveLapse (heartbeat like) (now managed by requests)

executeRPC(method, *args)

Calls a remote service

Parameters:
  • method (str) – remote procedure name

  • args – list of arguments

Returns:

decoded response from server, server may return S_OK or S_ERROR

getDestinationService()

Returns the url the service.

getServiceName()

Returns the name of the service, if you had given a url at init, returns the URL.

receiveFile(destFile, *args)

Equivalent of receiveFile()

In practice, it calls the remote method streamToClient and stores the raw result in a file

Parameters:
  • destFile – file (or path) where to store the result

  • args – list of arguments

Returns:

S_OK/S_ERROR

sendFile(filename, fileID)

Equivalent of sendFile()

In practice, it calls the remote method streamFromClient and transfers the file as a string type value

Parameters:
  • filename (str) – file (or path) where to store the result

  • fileID (any) – tuple if file identifiers

Returns:

S_OK/S_ERROR result of the remote RPC call

DIRAC.Core.Tornado.Client.TornadoClient.executeRPCStub(rpcStub)

Playback a stub # Copy-paste from DIRAC.Core.DISET.RPCClient with RPCClient changed into TornadoClient