| Server IP : 104.21.37.246 / Your IP : 172.71.28.146 [ Web Server : Apache System : Linux cpanel01wh.bkk1.cloud.z.com 2.6.32-954.3.5.lve1.4.59.el6.x86_64 #1 SMP Thu Dec 6 05:11:00 EST 2018 x86_64 User : cp648411 ( 1354) PHP Version : 7.2.34 Disable Function : NONE Domains : 0 Domains MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /opt/alt/python27/lib/python2.7/site-packages/raven/utils/ |
Upload File : |
from __future__ import absolute_import
from threading import local
class TransactionContext(object):
def __init__(self, stack, context):
self.stack = stack
self.context = context
def __enter__(self):
self.stack.push(self.context)
return self
def __exit__(self, *exc_info):
self.stack.pop(self.context)
class TransactionStack(local):
def __init__(self):
self.stack = []
def __len__(self):
return len(self.stack)
def __iter__(self):
return iter(self.stack)
def __call__(self, context):
return TransactionContext(self, context)
def clear(self):
self.stack = []
def peek(self):
try:
return self.stack[-1]
except IndexError:
return None
def push(self, context):
self.stack.append(context)
return context
def pop(self, context=None):
if context is None:
return self.stack.pop()
while self.stack:
if self.stack.pop() is context:
return context