Commit e50f0216 authored by Mathieu Westphal's avatar Mathieu Westphal

Adding a dynamic timeout configurable when connecting to a server

This adds a timeout, configurable just before connecting
to any non reverse server.
This also adds the corresponding python wrapping/
parent eccd05e0
# Connection Server Timeout
Adding a line edit to set the timeout to use when connecting to a server.
The feature has been added as an optional parameter to the different python `Connect` methods.
......@@ -106,10 +106,6 @@ vtkMultiProcessController* vtkTCPNetworkAccessManager::NewConnection(const char*
if (parameters.find("timeout") != parameters.end())
{
timeout_in_seconds = atoi(parameters["timeout"].c_str());
if (timeout_in_seconds < 0)
{
timeout_in_seconds = 0;
}
}
this->WrongConnectID = false;
......@@ -389,13 +385,20 @@ vtkMultiProcessController* vtkTCPNetworkAccessManager::ConnectToRemote(
break;
}
timer->StopTimer();
if (timeout_in_seconds <= 0 || timer->GetElapsedTime() > timeout_in_seconds)
if (timeout_in_seconds >= 0)
{
vtkErrorMacro(<< "Connect timeout.");
return NULL;
if (timeout_in_seconds == 0 || timer->GetElapsedTime() > timeout_in_seconds)
{
vtkErrorMacro(<< "Connect timeout.");
return NULL;
}
vtkWarningMacro(<< "Connect failed. Retrying for "
<< (timeout_in_seconds - timer->GetElapsedTime()) << " more seconds.");
}
else
{
vtkWarningMacro("Connect failed. Retrying.");
}
vtkWarningMacro(<< "Connect failed. Retrying for "
<< (timeout_in_seconds - timer->GetElapsedTime()) << " more seconds.");
vtksys::SystemTools::Delay(1000);
}
......
......@@ -68,8 +68,8 @@ public:
* It leaves the server socket open for client to connect.
* timeout :- When connecting to remote i.e listen==false, specify the time
* (in seconds) for which this call blocks to retry attempts to
* connect to the host/port. If absent, default is 60s. 0 or
* negative implies no retry attempts.
* connect to the host/port. If absent, default is 60s. 0 implies no retry attempts.
* A negative value implies an infinite number of retries.
*/
vtkMultiProcessController* NewConnection(const char* url) VTK_OVERRIDE;
......
......@@ -287,7 +287,7 @@ void vtkSMSession::Disconnect(vtkIdType sid)
}
//----------------------------------------------------------------------------
vtkIdType vtkSMSession::ConnectToSelf()
vtkIdType vtkSMSession::ConnectToSelf(int timeout)
{
vtkProcessModule* pm = vtkProcessModule::GetProcessModule();
vtkIdType sid = 0;
......@@ -297,7 +297,7 @@ vtkIdType vtkSMSession::ConnectToSelf()
int port = vtkSMSession::AutoMPI->ConnectToRemoteBuiltInSelf();
if (port > 0)
{
sid = vtkSMSession::ConnectToRemoteInternal("localhost", port, true);
sid = vtkSMSession::ConnectToRemoteInternal("localhost", port, true, timeout);
if (sid > 0)
{
return sid;
......@@ -326,20 +326,21 @@ vtkIdType vtkSMSession::ConnectToCatalyst()
}
//----------------------------------------------------------------------------
vtkIdType vtkSMSession::ConnectToRemote(const char* hostname, int port)
vtkIdType vtkSMSession::ConnectToRemote(const char* hostname, int port, int timeout)
{
return vtkSMSession::ConnectToRemoteInternal(hostname, port, false);
return vtkSMSession::ConnectToRemoteInternal(hostname, port, false, timeout);
}
//----------------------------------------------------------------------------
vtkIdType vtkSMSession::ConnectToRemoteInternal(const char* hostname, int port, bool is_auto_mpi)
vtkIdType vtkSMSession::ConnectToRemoteInternal(
const char* hostname, int port, bool is_auto_mpi, int timeout)
{
std::ostringstream sname;
sname << "cs://" << hostname << ":" << port;
vtkSMSessionClient* session = vtkSMSessionClient::New();
session->IsAutoMPI = is_auto_mpi;
vtkIdType sid = 0;
if (session->Connect(sname.str().c_str()))
if (session->Connect(sname.str().c_str(), timeout))
{
vtkProcessModule* pm = vtkProcessModule::GetProcessModule();
sid = pm->RegisterSession(session);
......@@ -350,13 +351,13 @@ vtkIdType vtkSMSession::ConnectToRemoteInternal(const char* hostname, int port,
//----------------------------------------------------------------------------
vtkIdType vtkSMSession::ConnectToRemote(
const char* dshost, int dsport, const char* rshost, int rsport)
const char* dshost, int dsport, const char* rshost, int rsport, int timeout)
{
std::ostringstream sname;
sname << "cdsrs://" << dshost << ":" << dsport << "/" << rshost << ":" << rsport;
vtkSMSessionClient* session = vtkSMSessionClient::New();
vtkIdType sid = 0;
if (session->Connect(sname.str().c_str()))
if (session->Connect(sname.str().c_str(), timeout))
{
vtkProcessModule* pm = vtkProcessModule::GetProcessModule();
sid = pm->RegisterSession(session);
......
......@@ -177,18 +177,20 @@ public:
/**
* These are static helper methods that help create standard ParaView
* sessions. They register the session with the process module and return the
* session id. Returns 0 on failure.
* session id. It will try to connect for timeout seconds, -1 meaning infinite retries.
* and 0 means no retry. Returns 0 on failure.
* This overload is used to create a built-in session.
*/
static vtkIdType ConnectToSelf();
static vtkIdType ConnectToSelf(int timeout = 60);
/**
* These are static helper methods that help create standard ParaView
* sessions. They register the session with the process module and return the
* session id. Returns 0 on failure.
* session id. It will try to connect for timeout seconds, -1 meaning infinite retries.
* and 0 means no retry. Returns 0 on failure. Returns 0 on failure.
* This overload is used to create a client-server session on client.
*/
static vtkIdType ConnectToRemote(const char* hostname, int port);
static vtkIdType ConnectToRemote(const char* hostname, int port, int timeout = 60);
/**
* Same as ConnectToRemote() except that it waits for a reverse connection.
......@@ -206,11 +208,12 @@ public:
/**
* These are static helper methods that help create standard ParaView
* sessions. They register the session with the process module and return the
* session id. Returns 0 on failure.
* This overload is used to create a client-dataserver-renderserver session on
* client.
* session id. It will try to connect for timeout seconds, -1 meaning infinite retries.
* and 0 means no retry. Returns 0 on failure.
* This overload is used to create a client-dataserver-renderserver session on client.
*/
static vtkIdType ConnectToRemote(const char* dshost, int dsport, const char* rshost, int rsport);
static vtkIdType ConnectToRemote(
const char* dshost, int dsport, const char* rshost, int rsport, int timeout = 60);
/**
* Same as ConnectToRemote() except that it waits for a reverse connection.
......@@ -256,7 +259,8 @@ protected:
/**
* Internal method used by ConnectToRemote().
*/
static vtkIdType ConnectToRemoteInternal(const char* hostname, int port, bool is_auto_mpi);
static vtkIdType ConnectToRemoteInternal(
const char* hostname, int port, bool is_auto_mpi, int timeout = 60);
/**
* Process the Notifation message sent using API to communicate from
......
......@@ -147,7 +147,7 @@ vtkMultiProcessController* vtkSMSessionClient::GetController(ServerFlags process
}
//----------------------------------------------------------------------------
bool vtkSMSessionClient::Connect(const char* url)
bool vtkSMSessionClient::Connect(const char* url, int timeout)
{
this->SetURI(url);
vtksys::RegularExpression pvserver("^cs://([^:]+)(:([0-9]+))?");
......@@ -160,6 +160,10 @@ bool vtkSMSessionClient::Connect(const char* url)
vtkProcessModule* pm = vtkProcessModule::GetProcessModule();
vtkPVOptions* options = pm->GetOptions();
// generate timeout string in seconds.
std::ostringstream timeoutString;
timeoutString << "timeout=" << timeout << "&";
std::ostringstream handshake;
handshake << "handshake=paraview-" << PARAVIEW_VERSION;
// Add connect-id if needed. The connect-id is added to the handshake that
......@@ -181,7 +185,7 @@ bool vtkSMSessionClient::Connect(const char* url)
port = (port <= 0) ? 11111 : port;
std::ostringstream stream;
stream << "tcp://" << hostname << ":" << port << "?" << handshake.str();
stream << "tcp://" << hostname << ":" << port << "?" << timeoutString.str() << handshake.str();
data_server_url = stream.str();
}
else if (pvserver_reverse.find(url))
......@@ -190,7 +194,8 @@ bool vtkSMSessionClient::Connect(const char* url)
int port = atoi(pvserver_reverse.match(3).c_str());
port = (port < 0) ? 11111 : port;
std::ostringstream stream;
stream << "tcp://localhost:" << port << "?listen=true&nonblocking=true&" << handshake.str();
stream << "tcp://localhost:" << port << "?listen=true&nonblocking=true&" << timeoutString.str()
<< handshake.str();
data_server_url = stream.str();
}
else if (pvrenderserver.find(url))
......@@ -204,11 +209,13 @@ bool vtkSMSessionClient::Connect(const char* url)
rsport = (rsport <= 0) ? 22221 : rsport;
std::ostringstream stream;
stream << "tcp://" << dataserverhost << ":" << dsport << "?" << handshake.str();
stream << "tcp://" << dataserverhost << ":" << dsport << "?" << timeoutString.str()
<< handshake.str();
data_server_url = stream.str().c_str();
std::ostringstream stream2;
stream2 << "tcp://" << renderserverhost << ":" << rsport << "?" << handshake.str();
stream2 << "tcp://" << renderserverhost << ":" << rsport << "?" << timeoutString.str()
<< handshake.str();
render_server_url = stream2.str();
}
else if (pvrenderserver_reverse.find(url))
......@@ -220,11 +227,13 @@ bool vtkSMSessionClient::Connect(const char* url)
rsport = (rsport < 0) ? 22221 : rsport;
std::ostringstream stream;
stream << "tcp://localhost:" << dsport << "?listen=true&nonblocking=true&" << handshake.str();
stream << "tcp://localhost:" << dsport << "?listen=true&nonblocking=true&"
<< timeoutString.str() << handshake.str();
data_server_url = stream.str().c_str();
std::ostringstream stream2;
stream2 << "tcp://localhost:" << rsport << "?listen=true&nonblocking=true&" << handshake.str();
stream2 << "tcp://localhost:" << rsport << "?listen=true&nonblocking=true&"
<< timeoutString.str() << handshake.str();
render_server_url = stream2.str();
}
......
......@@ -56,8 +56,10 @@ public:
* csrc://<pvserver-host>:<pvserver-port>
* cdsrsrc://<pvdataserver-host>:<pvdataserver-port>/<pvrenderserver-host>:<pvrenderserver-port>
* In this case, the hostname is irrelevant and is ignored.
* Wait for timeout seconds for the connection. Default is 60, 0 means no retry.
* -1 means infinite retries.
*/
virtual bool Connect(const char* url);
virtual bool Connect(const char* url, int timeout = 60);
/**
* Returns true is this session is active/alive/valid.
......
......@@ -110,6 +110,29 @@
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="timeoutLabel">
<property name="text">
<string>Timeout (s) </string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="timeoutSpinBox">
<property name="toolTip">
<string>Specify the timeout in seconds to use when connecting to the server. 0 means no retry. -1 means infinite retries.</string>
</property>
<property name="value">
<number>60</number>
</property>
<property name="minimum">
<number>-1</number>
</property>
<property name="maximum">
<number>9999</number>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="connect">
<property name="enabled">
......
......@@ -327,6 +327,8 @@ void pqServerConnectDialog::updateButtons()
this->Internals->editServer->setEnabled(false);
this->Internals->deleteServer->setEnabled(false);
this->Internals->connect->setEnabled(false);
this->Internals->timeoutLabel->setVisible(false);
this->Internals->timeoutSpinBox->setVisible(false);
return;
}
......@@ -337,13 +339,17 @@ void pqServerConnectDialog::updateButtons()
int original_index = this->Internals->servers->item(row, 0)->data(Qt::UserRole).toInt();
bool is_mutable = false;
bool isReverse = false;
if (original_index >= 0 && original_index < this->Internals->servers->rowCount())
{
is_mutable = this->Internals->Configurations[original_index].isMutable();
isReverse = this->Internals->Configurations[original_index].resource().isReverse();
}
this->Internals->editServer->setEnabled(is_mutable);
this->Internals->deleteServer->setEnabled(is_mutable);
this->Internals->connect->setEnabled(true);
this->Internals->timeoutLabel->setVisible(!isReverse);
this->Internals->timeoutSpinBox->setVisible(!isReverse);
}
}
......@@ -674,6 +680,7 @@ void pqServerConnectDialog::connect()
Q_ASSERT(original_index >= 0 && original_index < this->Internals->Configurations.size());
this->Internals->ToConnect = this->Internals->Configurations[original_index];
this->Internals->ToConnect.setConnectionTimeout(this->Internals->timeoutSpinBox->value());
this->accept();
}
......
......@@ -624,7 +624,8 @@ bool pqServerLauncher::connectToPrelaunchedServer()
}
const pqServerResource& resource = this->Internals->Configuration.resource();
this->Internals->Server = builder->createServer(resource);
this->Internals->Server =
builder->createServer(resource, this->Internals->Configuration.connectionTimeout());
return this->Internals->Server != NULL;
}
......
......@@ -626,7 +626,7 @@ void pqObjectBuilder::abortPendingConnections()
}
//-----------------------------------------------------------------------------
pqServer* pqObjectBuilder::createServer(const pqServerResource& resource)
pqServer* pqObjectBuilder::createServer(const pqServerResource& resource, int connectionTimeout)
{
if (this->WaitingForConnection)
{
......@@ -668,11 +668,12 @@ pqServer* pqObjectBuilder::createServer(const pqServerResource& resource)
vtkIdType id = 0;
if (server_resource.scheme() == "builtin")
{
id = vtkSMSession::ConnectToSelf();
id = vtkSMSession::ConnectToSelf(connectionTimeout);
}
else if (server_resource.scheme() == "cs")
{
id = vtkSMSession::ConnectToRemote(resource.host().toLocal8Bit().data(), resource.port(11111));
id = vtkSMSession::ConnectToRemote(
resource.host().toLocal8Bit().data(), resource.port(11111), connectionTimeout);
}
else if (server_resource.scheme() == "csrc")
{
......@@ -685,7 +686,7 @@ pqServer* pqObjectBuilder::createServer(const pqServerResource& resource)
id = vtkSMSession::ConnectToRemote(server_resource.dataServerHost().toLocal8Bit().data(),
server_resource.dataServerPort(11111),
server_resource.renderServerHost().toLocal8Bit().data(),
server_resource.renderServerPort(22221));
server_resource.renderServerPort(22221), connectionTimeout);
}
else if (server_resource.scheme() == "cdsrsrc")
{
......
......@@ -82,11 +82,12 @@ public:
* MultipleConnectionsSupport to true. In that case
* this will always try to connect the server using the details specified in
* the resource irrespective if the server is already connected or any other
* server connections exists.
* server connections exists and will wait for timeout seconds for direct connection.
* 0 means no retry, -1 means infinite retries.
* Calling this method while waiting for a previous server connection to be
* established raises errors.
*/
pqServer* createServer(const pqServerResource& resource);
pqServer* createServer(const pqServerResource& resource, int connectionTimeout = 60);
/**
* Destroy a server connection
......
......@@ -48,20 +48,21 @@ pqServerConfiguration::pqServerConfiguration()
vtkNew<vtkPVXMLParser> parser;
parser->Parse("<Server name='" SERVER_CONFIGURATION_DEFAULT_NAME
"' configuration=''><ManualStartup/></Server>");
this->constructor(parser->GetRootElement());
this->constructor(parser->GetRootElement(), 60);
}
//-----------------------------------------------------------------------------
pqServerConfiguration::pqServerConfiguration(vtkPVXMLElement* xml)
pqServerConfiguration::pqServerConfiguration(vtkPVXMLElement* xml, int connectionTimeout)
{
this->constructor(xml);
this->constructor(xml, connectionTimeout);
}
//-----------------------------------------------------------------------------
void pqServerConfiguration::constructor(vtkPVXMLElement* xml)
void pqServerConfiguration::constructor(vtkPVXMLElement* xml, int connectionTimeout)
{
Q_ASSERT(xml && xml->GetName() && strcmp(xml->GetName(), "Server") == 0);
this->XML = xml;
this->ConnectionTimeout = connectionTimeout;
this->Mutable = true;
}
......@@ -106,6 +107,18 @@ void pqServerConfiguration::setResource(const QString& str)
this->XML->SetAttribute("resource", str.toLocal8Bit().data());
}
//-----------------------------------------------------------------------------
int pqServerConfiguration::connectionTimeout() const
{
return this->ConnectionTimeout;
}
//-----------------------------------------------------------------------------
void pqServerConfiguration::setConnectionTimeout(int connectionTimeout)
{
this->ConnectionTimeout = connectionTimeout;
}
//-----------------------------------------------------------------------------
pqServerConfiguration::StartupType pqServerConfiguration::startupType() const
{
......@@ -292,5 +305,5 @@ pqServerConfiguration pqServerConfiguration::clone() const
{
vtkNew<vtkPVXMLElement> xml;
this->XML->CopyTo(xml.GetPointer());
return pqServerConfiguration(xml.GetPointer());
return pqServerConfiguration(xml.GetPointer(), this->ConnectionTimeout);
}
......@@ -48,9 +48,14 @@ class PQCORE_EXPORT pqServerConfiguration
{
public:
pqServerConfiguration();
pqServerConfiguration(vtkPVXMLElement* xml);
~pqServerConfiguration();
/**
* Create a server configuration with the provided xml and timeout.
* the timeout is in seconds, 0 means no retry and -1 means infinite retries.
*/
pqServerConfiguration(vtkPVXMLElement* xml, int connectionTimeout = 60);
/**
* Get/Set whether the configuration is mutable. This variable is not
* serialized.
......@@ -78,6 +83,13 @@ public:
void setResource(const pqServerResource&);
void setResource(const QString&);
/**
* Get/Set the timeout in seconds that will be used when connecting
* 0 means no retry and -1 means infinite retries.
*/
int connectionTimeout() const;
void setConnectionTimeout(int connectionTimeout);
/**
* Types of start
*/
......@@ -135,8 +147,9 @@ protected:
vtkPVXMLElement* startupXML() const;
private:
void constructor(vtkPVXMLElement*);
void constructor(vtkPVXMLElement*, int connectionTimeout = 60);
bool Mutable;
int ConnectionTimeout;
vtkSmartPointer<vtkPVXMLElement> XML;
};
......
......@@ -265,6 +265,11 @@ void pqServerResource::setScheme(const QString& rhs)
this->Implementation->Scheme = rhs;
}
bool pqServerResource::isReverse() const
{
return (this->Implementation->Scheme == "csrc" || this->Implementation->Scheme == "cdsrsrc");
}
const QString pqServerResource::host() const
{
if (this->Implementation->Scheme == "cdsrs" || this->Implementation->Scheme == "cdsrsrc")
......
......@@ -129,11 +129,17 @@ public:
/** Returns the resource scheme -
builtin, cs, csrc, cdsrs, cdsrsrc, or session */
const QString scheme() const;
/**
* Sets the resource scheme
*/
void setScheme(const QString&);
/**
* Returns if the connection scheme is a reverse one
*/
bool isReverse() const;
/** Returns the resource host, or empty string for builtin, session,
cdsrs, and cdsrsrc schemes */
const QString host() const;
......
......@@ -201,7 +201,6 @@ class Proxy(object):
for property in proxy:
print (property)
For advanced users:
This is a python class that wraps a vtkSMProxy. Makes it easier to
set/get properties.
......@@ -572,7 +571,6 @@ class SourceProxy(Proxy):
CellData = property(GetCellDataInformation, None, None, "Returns cell data information")
FieldData = property(GetFieldDataInformation, None, None, "Returns field data information")
class ExodusIIReaderProxy(SourceProxy):
"""Special class to define convenience functions for array
selection."""
......@@ -932,7 +930,6 @@ class EnumerationProperty(VectorProperty):
Available = property(GetAvailable, None, None, \
"This read-only property contains the list of values that can be applied to this property.")
class FileNameProperty(VectorProperty):
"""Property to set/get one or more file names.
This property updates the pipeline information everytime its value changes.
......@@ -1120,7 +1117,6 @@ class ArrayListProperty(VectorProperty):
fullvalues.append(val)
fullvalues.append('1')
i = 0
for value in fullvalues:
self.SMProperty.SetElement(i, value)
......@@ -1141,7 +1137,6 @@ class ArrayListProperty(VectorProperty):
self.__arrays.append(self.GetElement(i))
return list(self.__arrays)
class SubsetInclusionLatticeProperty(ArrayListProperty):
"""This property provides a simpler interface for selecting blocks on a
property with a `vtkSMSubsetInclusionLatticeDomain`."""
......@@ -1149,7 +1144,6 @@ class SubsetInclusionLatticeProperty(ArrayListProperty):
# forward select/deselect requests to a vtkSubsetInclusionLattice instance.
pass
class ProxyProperty(Property):
"""A ProxyProperty provides access to one or more proxies. You can use
a slice to get one or more property values:
......@@ -1405,7 +1399,6 @@ class InputProperty(ProxyProperty):
if isinstance(prop, ArraySelectionProperty):
prop.UpdateDefault()
class DataInformation(object):
"""DataInformation is a contained for meta-data associated with an
output data.
......@@ -1519,7 +1512,6 @@ class FieldDataInformationIterator(object):
return ai
__next__ = next # Python 3.X compatibility
class FieldDataInformation(object):
"""Meta-data for a field of an output object (point data, cell data etc...).
Provides easy access to the arrays using the slice interface:
......@@ -1902,7 +1894,6 @@ class ProxyDefinitionIterator(object):
"""returns attributes from the vtkPVProxyDefinitionIterator."""
return getattr(self.SMIterator, name)
class ProxyIterator(object):
"""Wrapper for a vtkSMProxyIterator class to satisfy the
python iterator protocol.
......@@ -2063,7 +2054,7 @@ def LoadState(filename, connection=None):
view.GetRenderWindow().SetSize(view.ViewSize[0], \
view.ViewSize[1])
def Connect(ds_host=None, ds_port=11111, rs_host=None, rs_port=22221):
def Connect(ds_host=None, ds_port=11111, rs_host=None, rs_port=22221, timeout=60):
"""
Use this function call to create a new session. On success,
it returns a vtkSMSession object that abstracts the connection.
......@@ -2071,7 +2062,7 @@ def Connect(ds_host=None, ds_port=11111, rs_host=None, rs_port=22221):
There are several ways in which this function can be called:
* When called with no arguments, it creates a new session
* When called with no hosts, it creates a new session
to the built-in server on the client itself.
* When called with ds_host and ds_port arguments, it
......@@ -2081,22 +2072,29 @@ def Connect(ds_host=None, ds_port=11111, rs_host=None, rs_port=22221):
* When called with ds_host, ds_port, rs_host, rs_port, it
creates a new connection to the data server on ds_host:ds_port and to the
render server on rs_host: rs_port.
* All these connection types support a timeout argument in second.
Default is 60. 0 means no retry, -1 means infinite retries.
"""
ret = True;
if ds_host == None:
session = vtkSMSession()
elif rs_host == None:
session = vtkSMSessionClient()
session.Connect("cs://%s:%d" % (ds_host, ds_port))
ret = session.Connect("cs://%s:%d" % (ds_host, ds_port), timeout)
else:
session = vtkSMSessionClient()
session.Connect("cdsrs://%s:%d/%s:%d" % (ds_host, ds_port, rs_host, rs_port))
id = vtkProcessModule.GetProcessModule().RegisterSession(session)
connection = GetConnectionFromId(id)
# This shouldn't be needed. However, it's needed for old Python scripts that
# directly import servermanager.py without simple.py
SetActiveConnection(connection)
return connection
ret = session.Connect("cdsrs://%s:%d/%s:%d" % (ds_host, ds_port, rs_host, rs_port), timeout)
if ret:
id = vtkProcessModule.GetProcessModule().RegisterSession(session)
connection = GetConnectionFromId(id)
# This shouldn't be needed. However, it's needed for old Python scripts that
# directly import servermanager.py without simple.py
SetActiveConnection(connection)
return connection
else:
return None
def ReverseConnect(port=11111):
"""
......@@ -2262,7 +2260,6 @@ def LoadXML(xmlstring):
"""DEPRECATED. Given a server manager XML as a string, parse and process it."""
raise RuntimeError ("Deprecated. Use LoadPlugin(...) instead.")
def LoadPlugin(filename, remote=True, connection=None):
""" Given a filename and a session (optional, otherwise uses
ActiveConnection), loads a plugin. It then updates the sources,
......@@ -2286,7 +2283,6 @@ def LoadPlugin(filename, remote=True, connection=None):
# we should never have to call this. The modules should update automatically.
updateModules(connection.Modules)
def Fetch(input, arg1=None, arg2=None, idx=0):
"""
A convenience method that moves data from the server to the client,
......@@ -2396,7 +2392,6 @@ def AnimateReader(reader, view):
if not view in tk.Views:
tk.Views.append(view)
# with 1 view
scene.ViewModules = [view]
# Update the reader to get the time information
......@@ -2736,7 +2731,6 @@ def createModule(groupName, mdl=None):
mdl.__dict__[pname] = cobj
return mdl
def __determineGroup(proxy):
"""Internal method"""
if not proxy:
......@@ -3037,7 +3031,6 @@ def demo4(fname="/Users/berk/Work/ParaViewData/Data/can.ex2"):
c.Elevation(95)
return AnimateReader(reader, view)
def demo5():
""" Simple sphere animation"""
if not ActiveConnection:
......@@ -3195,7 +3188,6 @@ _pyproxies = {}
loader = _ModuleLoader()
sys.meta_path.append(loader)
def __exposeActiveModules__():
"""Update servermanager submodules to point to the current
ActiveConnection.Modules.*"""
......@@ -3232,7 +3224,6 @@ def GetConnectionFromSession(session):
return c
return None
def __connectionCreatedCallback(obj, string):
"""Callback called when a new session is created."""
global Connections
......
......@@ -81,16 +81,20 @@ def Disconnect(ns=None, force=True):
# -----------------------------------------------------------------------------
def Connect(ds_host=None, ds_port=11111, rs_host=None, rs_port=11111):
def Connect(ds_host=None, ds_port=11111, rs_host=None, rs_port=11111, timeout = 60):
"""Creates a connection to a server. Example usage::
> Connect("amber") # Connect to a single server at default port
> Connect("amber", 12345) # Connect to a single server at port 12345
> Connect("amber", 11111, "vis_cluster", 11111) # connect to data server, render server pair"""
> Connect("amber", 11111, "vis_cluster", 11111) # connect to data server, render server pair
> Connect("amber", timeout=30) # Connect to a single server at default port with a 30s timeout instead of default 60s
> Connect("amber", timeout=-1) # Connect to a single server at default port with no timeout instead of default 60s
> Connect("amber", timeout=0) # Connect to a single server at default port without retrying instead of retrying for the default 60s"""
Disconnect(globals(), False)
connection = servermanager.Connect(ds_host, ds_port, rs_host, rs_port)
_initializeSession(connection)
_add_functions(globals())
connection = servermanager.Connect(ds_host, ds_port, rs_host, rs_port, timeout)
if not (connection is None):
_initializeSession(connection)
_add_functions(globals())
return connection
# -----------------------------------------------------------------------------
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment