本文整理汇总了Python中stackless.getcurrent方法的典型用法代码示例。如果您正苦于以下问题:Python stackless.getcurrent方法的具体用法?Python stackless.getcurrent怎么用?Python stackless.getcurrent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类stackless
的用法示例。
在下文中一共展示了stackless.getcurrent方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_id
# 需要导入模块: import stackless [as 别名]
# 或者: from stackless import getcurrent [as 别名]
def get_id():
return greenlet.getcurrent(), stackless.getcurrent()
示例2: _stackless_schedule_cb
# 需要导入模块: import stackless [as 别名]
# 或者: from stackless import getcurrent [as 别名]
def _stackless_schedule_cb(self, prev, next):
current = stackless.getcurrent()
if not current:
return
current_tf = current.trace_function
try:
current.trace_function = None
self.stepping = STEPPING_NONE
# If the current frame has no trace function, we may need to get it
# from the previous frame, depending on how we ended up in the
# callback.
if current_tf is None:
f_back = current.frame.f_back
if f_back is not None:
current_tf = f_back.f_trace
if next is not None:
# Assign our trace function to the current stack
f = next.frame
if next is current:
f = f.f_back
while f:
if isinstance(f, types.FrameType):
f.f_trace = self.trace_func
f = f.f_back
next.trace_function = self.trace_func
finally:
current.trace_function = current_tf
示例3: getcurrent
# 需要导入模块: import stackless [as 别名]
# 或者: from stackless import getcurrent [as 别名]
def getcurrent():
return tasklet_to_greenlet[stackless.getcurrent()]
示例4: __init__
# 需要导入模块: import stackless [as 别名]
# 或者: from stackless import getcurrent [as 别名]
def __init__(self, run=None, parent=None):
self.dead = False
if parent is None:
parent = getcurrent()
self.parent = parent
if run is not None:
self.run = run
self.switch = FirstSwitch(self)
示例5: switch
# 需要导入模块: import stackless [as 别名]
# 或者: from stackless import getcurrent [as 别名]
def switch(self, *args):
# print("switch", args)
global caller
caller = stackless.getcurrent()
coro_args[self] = args
self.t.insert()
stackless.schedule()
if caller is not self.t:
caller.remove()
rval = coro_args[self]
return rval
示例6: emulate
# 需要导入模块: import stackless [as 别名]
# 或者: from stackless import getcurrent [as 别名]
def emulate():
module = types.ModuleType('greenlet')
sys.modules['greenlet'] = module
module.greenlet = greenlet
module.getcurrent = getcurrent
module.GreenletExit = GreenletExit
caller = stackless.getcurrent()
tasklet_to_greenlet[caller] = None
main_coro = greenlet()
tasklet_to_greenlet[caller] = main_coro
main_coro.t = caller
del main_coro.switch # It's already running
coro_args[main_coro] = None
示例7: __AddMessage
# 需要导入模块: import stackless [as 别名]
# 或者: from stackless import getcurrent [as 别名]
def __AddMessage(self,char,system): #????
old=stackless.getcurrent().set_atomic(True)
try:
if system not in self.__cachemsgs:
self.__cachemsgs[system]=[]
self.__cachemsgs[system].append(char)
finally:
stackless.getcurrent().set_atomic(old)
示例8: __SendMessage
# 需要导入模块: import stackless [as 别名]
# 或者: from stackless import getcurrent [as 别名]
def __SendMessage(self): #????
old=stackless.getcurrent().set_atomic(True)
try:
for key in self.__cachemsgs:
msg=""
if len(self.__cachemsgs[key]) > self.__MAX_NAME_PER_SYSTEM:
msg=key+" "+str(len(self.__cachemsgs[key]))+" hostile(s)"
else:
msg=key
for name in self.__cachemsgs[key]:
msg+=" "+name
sm.GetService('LSC').SendMessage(self.__alertchannel, msg) # ??????
sm.GetService('LSC').GetChannelWindow(self.__alertchannel).Speak(msg, eve.session.charid,localEcho=True)
finally:
stackless.getcurrent().set_atomic(old)