本文整理汇总了Python中models.Session.create_time方法的典型用法代码示例。如果您正苦于以下问题:Python Session.create_time方法的具体用法?Python Session.create_time怎么用?Python Session.create_time使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Session
的用法示例。
在下文中一共展示了Session.create_time方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _handle_create
# 需要导入模块: from models import Session [as 别名]
# 或者: from models.Session import create_time [as 别名]
def _handle_create(self, e):
'''Handle channel create events by building local
`Session` and `Call` objects for state tracking.
'''
uuid = e.getHeader('Unique-ID')
self.log.debug("channel created for session '{}'".format(uuid))
# Record the newly activated session
# TODO: pass con as weakref?
con = self._tx_con if not self._shared else None
sess = Session(event=e, con=con)
sess.cid = self.get_id(e, 'default')
# note the start time and current load
# TODO: move this to Session __init__??
sess.create_time = get_event_time(e)
# Use our special Xheader to try and associate sessions into calls
# (assumes that x-headers are forwarded by the proxy/B2BUA)
call_uuid = e.getHeader('variable_{}'.format(self.call_corr_xheader))
# If that fails then try using the freeswitch 'variable_call_uuid'
# (only works if bridging takes place locally)
if call_uuid is None:
call_uuid = e.getHeader(self.call_corr_var) # could be 'None'
if not call_uuid:
self.log.warn("Unable to associate session '{}' into calls"
.format(sess.uuid))
# associate sessions into a call
# (i.e. set the relevant sessions to reference each other)
if call_uuid in self.calls:
call = self.calls[call_uuid]
self.log.debug("session '{}' is bridged to call '{}'".format(
uuid, call.uuid))
# append this session to the call's set
call.append(sess)
else: # this sess is not yet tracked so use its id as the 'call' id
call = Call(call_uuid, sess)
self.calls[call_uuid] = call
self.log.debug("call created for session '{}'".format(call_uuid))
sess.call = call
self.sessions[uuid] = sess
return True, sess