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


Python Session.end方法代码示例

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


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

示例1: fake_session

# 需要导入模块: from session import Session [as 别名]
# 或者: from session.Session import end [as 别名]
def fake_session():
    session = Session()
    screenshots = load_all_screenshots( Paths.shots_dir )
    screenshots.sort( key=operator.attrgetter('time') )
    session_shots = screenshots[-100:]
    start_time = session_shots[0].time-1
    end_time = session_shots[-1].time+1
    session.start = start_time
    session.end = end_time
    api.create_session( session )
    api.start_session( session )
    map( upload_shot, session_shots )
    api.end_session( session )
开发者ID:futuro,项目名称:powershame-client,代码行数:15,代码来源:fake_session.py

示例2: connection

# 需要导入模块: from session import Session [as 别名]
# 或者: from session.Session import end [as 别名]
def connection():
  from connection import Connection
  from session import Session
  from link import Sender, Receiver, link
  from protocol import Fragment, Linkage

  a = Connection(lambda n: Session(n, link))
  b = Connection(lambda n: Session(n, link))
  a.id = "A"
  a.tracing = set(["ops", "err"])
  b.id = "B"
  b.tracing = set(["ops", "err"])

  def pump():
    while a.pending() or b.pending():
      b.write(a.read())
      a.write(b.read())

  s = Session("test-ssn", link)
  a.add(s)
  s2 = Session("test-ssn2", link)
  a.add(s2)

  a.open(hostname="asdf")
  b.open()
  s.begin()
  s2.begin()
  l = Sender("qwer", local=Linkage("S", "T"))
  s.add(l)
  l.attach()

  pump()

  bssn = [x for x in b.incoming.values() if x.name == "test-ssn"][0]
  bssn.begin()
  bl = bssn.links["qwer"]
  bl.attach()
  bl.flow(10)

  pump()

  l.settle(l.send(fragments=Fragment(True, True, 0, 0, "asdf")))
  tag = l.send(delivery_tag="blah", fragments=Fragment(True, True, 0, 0, "asdf"))

  pump()

  ln = bssn.links["qwer"]
  x = ln.get()
  print "INCOMING XFR:", x
  ln.disposition(x.delivery_tag, "ACCEPTED")

  xfr = ln.get()
  print "INCOMING XFR:", xfr
  ln.disposition(xfr.delivery_tag, "ASDF")

  print "--"

  pump()

  print "--"

  print "DISPOSITION", l.get_remote(modified=True)
  l.settle(tag)

  l.detach()
  bl.detach()

  pump()

  s.end(True)
  pump()
  bssn.end(True)
  s2.end(True)
  a.close()
  b.close()

  pump()
开发者ID:grkvlt,项目名称:amqp,代码行数:79,代码来源:test.py

示例3: __init__

# 需要导入模块: from session import Session [as 别名]
# 或者: from session.Session import end [as 别名]

#.........这里部分代码省略.........
        # trial
        if new_trial_flag:
            self.update_trial()
            
        # past
        if self.session.past_flag != False:
            cs,us = self.session.past_flag
            self.session.past_flag = False
            self.view.set_past_data(self.session.eyelid_buffer_ts,self.session.eyelid_buffer,cs,us)

        # pauses
        if self.session.paused:
            self.view.pause_button.SetLabel('Unpause')
            self.view.pause_button.SetBackgroundColour((0,255,0))
            self.view.start_button.Disable()
        elif not self.session.paused:
            self.view.pause_button.SetLabel('Pause')
            self.view.pause_button.SetBackgroundColour((0,150,150))
            if self.session.session_on and not self.session.session_kill:
                self.view.start_button.Enable()
        
        self.n_updates += 1
        self.update_timer = wx.CallLater(self.REFRESH_INTERVAL, self.update)

    def update_trial(self):
        if self.session.trial_idx < 0:
            return
        self.view.trial_n_widg.SetValue("%s"%(str(self.session.trial_idx)))
        self.view.trial_type_widg.SetValue(self.session.current_stim_state)

    ####### EVENTS ########
    def evt_prepare(self, evt):
        if self.state == self.STATE_PREPARED:
            self.session.end()
            self.update_state(self.STATE_NULL)

        else:
            sel_sub = self.view.sub_box.GetSelection()
            if wx.NOT_FOUND in [sel_sub]:
                dlg = wx.MessageDialog(self.view, message='Selections not made.', caption='Preparation not performed.', style=wx.OK)
                res = dlg.ShowModal()
                dlg.Destroy()
                return

            sub_name = self.view.sub_names[sel_sub]
            imaging = self.view.imaging_box.GetValue()

            sub = Subject(sub_name)
            ph = ParamHandler(sub, imaging=imaging)
            self.session = Session(ph.params, ax_interactive=self.view.ax_interactive)

            # tcpip communication
            if imaging:
                si_path = config.si_data_path+r'\\{}'.format(sub_name)
                seshname = self.session.name_as_str()
                dic = dict(path=si_path, name=seshname, idx=1)
                cont = True
                while cont:
                    suc = self.tcpip.send(dic)
                    if not suc:
                        dlg = wx.MessageDialog(self.view, caption='ScanImage preparation failed.', message='Try again?', style=wx.YES_NO)
                        res = dlg.ShowModal()
                        dlg.Destroy()
                        cont = res==wx.ID_YES
                        if cont:
                            self.evt_tcpip(None)
开发者ID:bensondaled,项目名称:eyeblink,代码行数:70,代码来源:controllers.py

示例4: __init__

# 需要导入模块: from session import Session [as 别名]
# 或者: from session.Session import end [as 别名]
class Session:

  def __init__(self, connection):
    self.proto = ProtoSession(link)
    self.connection = connection
    self._lock = self.connection._lock
    self.timeout = 120
    self.txn = None
    self.proto.begin()

  def wait(self, predicate, timeout=DEFAULT):
    if timeout is DEFAULT:
      self.timeout = timeout
    self.connection.wait(predicate, timeout)

  @synchronized
  def sender(self, target, name=None, unsettled=None):
    if isinstance(target, basestring):
      target = Target(address=target)
    snd = Sender(self.connection, name or str(uuid4()), target)
    self.proto.add(snd.proto)
    for k, v in (unsettled or {}).items():
      snd.proto.resume(k, v)
    snd.proto.attach()
    self.wait(lambda: snd.proto.attached() or snd.proto.detaching())
    if snd.proto.remote_target is None:
      snd.close()
      raise LinkError("no such target: %s" % target)
    else:
      snd.address = getattr(snd.proto.remote_target, "address", None)
      snd.unsettled = snd.proto.remote_unsettled()
    return snd

  @synchronized
  def receiver(self, source, limit=0, drain=False, name=None, unsettled=None):
    if isinstance(source, basestring):
      source = Source(address=source)
    rcv = Receiver(self.connection, name or str(uuid4()), source)
    self.proto.add(rcv.proto)
    if limit:
      rcv.flow(limit, drain=drain)
    for k, v in (unsettled or {}).items():
      rcv.proto.resume(k, v)
    rcv.proto.attach()
    self.wait(lambda: rcv.proto.attached() or rcv.proto.attaching())
    if rcv.proto.remote_source is None:
      rcv.close()
      raise LinkError("no such source: %s" % source)
    else:
      rcv.address = getattr(rcv.proto.remote_source, "address", None)
      rcv.unsettled = rcv.proto.remote_unsettled()
    return rcv

  @synchronized
  def incoming_window(self):
    return self.proto.incoming_window(self)

  @synchronized
  def set_incoming_window(self, *args, **kwargs):
    return self.proto.set_incoming_window(*args, **kwargs)

  def _txn_link(self):
    if self.txn is None:
      self.txn = self.sender(Coordinator(), "txn-%s" % uuid4())

  @synchronized
  def declare(self, timeout=None):
    self._txn_link()
    self.txn.send(Message(Declare(), delivery_tag="declare"))
    for t, l, r in self.txn.pending(block=True, timeout=timeout):
      if t == "declare":
        self.txn.settle(t)
        return r.state.txn_id
    else:
      raise SessionError("transaction declare failed")

  @synchronized
  def discharge(self, txn, fail=False, timeout=None):
    self._txn_link()
    self.txn.send(Message(Discharge(txn_id=txn, fail=fail), delivery_tag="discharge"))
    for t, l, r in self.txn.pending(block=True, timeout=timeout):
      if t == "discharge":
        self.txn.settle(t)
        break
    else:
      raise SessionError("transaction discharge failed")

  @synchronized
  def close(self):
    self.proto.end()
开发者ID:grkvlt,项目名称:amqp,代码行数:92,代码来源:client.py


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