当前位置: 首页>>代码示例>>Python>>正文


Python Driver.start方法代码示例

本文整理汇总了Python中driver.Driver.start方法的典型用法代码示例。如果您正苦于以下问题:Python Driver.start方法的具体用法?Python Driver.start怎么用?Python Driver.start使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在driver.Driver的用法示例。


在下文中一共展示了Driver.start方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: main

# 需要导入模块: from driver import Driver [as 别名]
# 或者: from driver.Driver import start [as 别名]
def main():
    database = Database()
    alarmLog = AlarmLog()
    summarizer = Summarizer(database, alarmLog)
    clock = Clock(summarizer)
    alarmWriter = AlarmWriter(summarizer)
    driver1 = Driver(1, summarizer)

    clock.start()
    alarmWriter.start()
    driver1.start()
    sleep(1000)
开发者ID:paskma,项目名称:framework-parlib,代码行数:14,代码来源:themain.py

示例2: Connection

# 需要导入模块: from driver import Driver [as 别名]
# 或者: from driver.Driver import start [as 别名]

#.........这里部分代码省略.........
    @rtype: Session
    @return: the named Session
    """

        if name is None:
            name = "%s:%s" % (self.id, self.session_counter)
            self.session_counter += 1
        else:
            name = "%s:%s" % (self.id, name)

        if self.sessions.has_key(name):
            return self.sessions[name]
        else:
            ssn = Session(self, name, transactional)
            self.sessions[name] = ssn
            self._wakeup()
            return ssn

    @synchronized
    def _remove_session(self, ssn):
        self.sessions.pop(ssn.name, 0)

    @synchronized
    def open(self, timeout=None):
        """
    Opens a connection.
    """
        if self._open:
            raise ConnectionError("already open")
        self._open = True
        if self.reconnect and self.reconnect_timeout > 0:
            timeout = self.reconnect_timeout
        self.attach(timeout=timeout)

    @synchronized
    def opened(self):
        """
    Return true if the connection is open, false otherwise.
    """
        return self._open

    @synchronized
    def attach(self, timeout=None):
        """
    Attach to the remote endpoint.
    """
        if not self._connected:
            self._connected = True
            self._driver.start()
            self._wakeup()
        if not self._ewait(lambda: self._transport_connected and not self._unlinked(), timeout=timeout):
            self.reconnect = False
            raise Timeout("Connection attach timed out")

    def _unlinked(self):
        return [
            l
            for ssn in self.sessions.values()
            if not (ssn.error or ssn.closed)
            for l in ssn.senders + ssn.receivers
            if not (l.linked or l.error or l.closed)
        ]

    @synchronized
    def detach(self, timeout=None):
        """
    Detach from the remote endpoint.
    """
        if self._connected:
            self._connected = False
            self._wakeup()
            cleanup = True
        else:
            cleanup = False
        try:
            if not self._wait(lambda: not self._transport_connected, timeout=timeout):
                raise Timeout("detach timed out")
        finally:
            if cleanup:
                self._driver.stop()
            self._condition.gc()

    @synchronized
    def attached(self):
        """
    Return true if the connection is attached, false otherwise.
    """
        return self._connected

    @synchronized
    def close(self, timeout=None):
        """
    Close the connection and all sessions.
    """
        try:
            for ssn in self.sessions.values():
                ssn.close(timeout=timeout)
        finally:
            self.detach(timeout=timeout)
            self._open = False
开发者ID:balagopalraj,项目名称:clearlinux,代码行数:104,代码来源:endpoints.py

示例3: open

# 需要导入模块: from driver import Driver [as 别名]
# 或者: from driver.Driver import start [as 别名]
class Connection:

  """
  A Connection manages a group of L{Sessions<Session>} and connects
  them with a remote endpoint.
  """

  @static
  def open(host, port=None, username="guest", password="guest",
           mechanism="PLAIN", heartbeat=None, **options):
    """
    Creates an AMQP connection and connects it to the given host and port.

    @type host: str
    @param host: the name or ip address of the remote host
    @type port: int
    @param port: the port number of the remote host
    @rtype: Connection
    @return: a connected Connection
    """
    conn = Connection(host, port, username, password, mechanism, heartbeat, **options)
    conn.connect()
    return conn

  def __init__(self, host, port=None, username="guest", password="guest",
               mechanism="PLAIN", heartbeat=None, **options):
    """
    Creates a connection. A newly created connection must be connected
    with the Connection.connect() method before it can be used.

    @type host: str
    @param host: the name or ip address of the remote host
    @type port: int
    @param port: the port number of the remote host
    @rtype: Connection
    @return: a disconnected Connection
    """
    self.host = host
    self.port = default(port, AMQP_PORT)
    self.username = username
    self.password = password
    self.mechanism = mechanism
    self.heartbeat = heartbeat

    self.id = str(uuid4())
    self.session_counter = 0
    self.sessions = {}
    self.reconnect = options.get("reconnect", False)
    self._connected = False
    self._lock = RLock()
    self._condition = Condition(self._lock)
    self._waiter = Waiter(self._condition)
    self._modcount = Serial(0)
    self.error = None
    from driver import Driver
    self._driver = Driver(self)
    self._driver.start()

  def _wait(self, predicate, timeout=None):
    return self._waiter.wait(predicate, timeout=timeout)

  def _wakeup(self):
    self._modcount += 1
    self._driver.wakeup()

  def _check_error(self, exc=ConnectionError):
    if self.error:
      raise exc(*self.error)

  def _ewait(self, predicate, timeout=None, exc=ConnectionError):
    result = self._wait(lambda: self.error or predicate(), timeout)
    self._check_error(exc)
    return result

  @synchronized
  def session(self, name=None, transactional=False):
    """
    Creates or retrieves the named session. If the name is omitted or
    None, then a unique name is chosen based on a randomly generated
    uuid.

    @type name: str
    @param name: the session name
    @rtype: Session
    @return: the named Session
    """

    if name is None:
      name = "%s:%s" % (self.id, self.session_counter)
      self.session_counter += 1
    else:
      name = "%s:%s" % (self.id, name)

    if self.sessions.has_key(name):
      return self.sessions[name]
    else:
      ssn = Session(self, name, transactional)
      self.sessions[name] = ssn
      self._wakeup()
      return ssn
#.........这里部分代码省略.........
开发者ID:KeithLatteri,项目名称:awips2,代码行数:103,代码来源:messaging.py

示例4: robot_thread

# 需要导入模块: from driver import Driver [as 别名]
# 或者: from driver.Driver import start [as 别名]
def robot_thread(event_kill):
  asyncio.set_event_loop(asyncio.new_event_loop())

  driver = Driver(webserver_queue=q)
  driver.start()
开发者ID:zacharylawrence,项目名称:ENEE408I-Team-9,代码行数:7,代码来源:main.py


注:本文中的driver.Driver.start方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。