本文整理汇总了Python中connector.Connector.disconnect方法的典型用法代码示例。如果您正苦于以下问题:Python Connector.disconnect方法的具体用法?Python Connector.disconnect怎么用?Python Connector.disconnect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类connector.Connector
的用法示例。
在下文中一共展示了Connector.disconnect方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: connect
# 需要导入模块: from connector import Connector [as 别名]
# 或者: from connector.Connector import disconnect [as 别名]
#.........这里部分代码省略.........
result = self.connection.Connection_Request(
password
) # Passing self.config to let the Connector set some connection data (e.g. the session_id)
else:
result = self.connection.Connection_Request()
self.is_connected = result
return result
## Checks if master and if affirmative, returns the slave
# @param target_name The target to connect to. If None gets the name from the default configuration
# @return The slave Target or False if not a master target
def getSlave(self, target_name=None):
if self.is_slave:
print "Can't ask for a slave to a slave. Try asking to a master."
return False
else:
# If target is not specified, caller are requesting a "standard" connection to the primary slave target
if not target_name:
target_name = self.config.getAttr("target_name")
slave = Target(
True,
self.config.getAttr("protocol"),
self.config.getAttr("address"),
self.config.getAttr("slave_port"),
target_name,
)
# Sets the session ID
slave.config.setAttr("session_id", self.config.session_id)
return slave
## Disconnects from the XML-RPC server
# @return The boolean result of the operation
def disconnect(self):
if self.is_slave:
result = self.connection.disconnect()
self.is_connected = result
return result
else:
print ("Can't call disconnect on master server")
return False
## Stops target server. This method, called on a master server, calls connector::Connector::stopServer and called on slave, calls connector::Connection::stopSlave
# @return The boolean result of the operation
def stop(self):
if self.is_slave:
# TODO: Stop the data thread if active
result = self.connection.stopSlaveServer()
self.is_connected = result
# Stops data threads
self.stop_data_threads()
return result
else:
result = self.connection.stopMasterServer()
self.is_connected = result
return result
## Closes the session
# @return The boolean result of the operation
def close(self):
result = self.connection.closeSession()
# Stops data threads
self.stop_data_threads()
self.is_connected = result
return result