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


Python Terminal.shell方法代码示例

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


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

示例1: Theatre

# 需要导入模块: from terminal import Terminal [as 别名]
# 或者: from terminal.Terminal import shell [as 别名]
class Theatre(object):
   
  def __init__(self, here, manager_loc, core_store, store_lock, current_id, id_lock, current_creator, creator_lock, port_range, f = None, args = None, kwds = None, ps = None):
    log.debug(self, 'starting')
    self.__here = here
    port = ids.port_from_loc(here)
    self.__shared_data = Shared(port, current_id, id_lock, core_store, store_lock, current_creator, creator_lock, port_range)    
    self.__actor_store = LocalActorStore(self.__here, self.__shared_data)
    self.__messenger = Messenger(here, self.__actor_store)
    self.__migrator = Migrator(here, self.__actor_store, self.__shared_data)
    self.__manager_loc = manager_loc
    self.__port_range = port_range
    self.__term = None
    self.__processes = ps
 
    if (port == port_range[0]):
      self.__term = Terminal(self, here)
    self.valve = rpc.RPCValve(port, self.external_interface(), log)
    set_local_theatre(self.internal_interface())
    self.valve.listen()
    print('Theatre created on port ' + str(port))
    
    vis.add_host(here)
              
    if (port != port_range[0]):
      while True:
        try:
          time.sleep(5)
        except:
          pass

    else:
      self.f = f
      self.f(*args, **kwds)
      self.__term.shell()
   
  def external_interface(self):
     return TheatreExternalInterface(self.__messenger, self.__migrator, self.__term, self, self.__actor_store)
   
  def internal_interface(self):
    return TheatreInternalInterface(self.__here, self.__messenger, self.__actor_store, self.__migrator, self.__manager_loc, self.__shared_data)
  
  def shutdown(self):
    for port in self.__port_range:
      if (port != self.__port_range[0]):
        network_locator = rpc.RPCConnector("127.0.0.1:" + str(port))
        locator = network_locator.connect()
        locator.shutdown()
        locator.disconnect()
    self.valve.shutdown()
    time.sleep(2)
    for p in self.__processes:
      p.terminate()
    time.sleep(2)        
    sys.exit()
    
  def __str__(self):
    return "Theatre" 
开发者ID:fredvdd,项目名称:Swan,代码行数:60,代码来源:theatre.py


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