本文整理汇总了Python中pyasm.search.DbContainer.close_all方法的典型用法代码示例。如果您正苦于以下问题:Python DbContainer.close_all方法的具体用法?Python DbContainer.close_all怎么用?Python DbContainer.close_all使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyasm.search.DbContainer
的用法示例。
在下文中一共展示了DbContainer.close_all方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: execute
# 需要导入模块: from pyasm.search import DbContainer [as 别名]
# 或者: from pyasm.search.DbContainer import close_all [as 别名]
def execute(self):
try:
#Batch()
#Command.execute_cmd(timed_trigger)
Project.set_project(self.project_code)
timed_triggers[self.index].execute()
except Exception as e:
raise
finally:
DbContainer.close_thread_sql()
DbContainer.commit_thread_sql()
DbContainer.close_all()
示例2: start
# 需要导入模块: from pyasm.search import DbContainer [as 别名]
# 或者: from pyasm.search.DbContainer import close_all [as 别名]
def start():
scheduler = Scheduler.get()
scheduler.start_thread()
task = TransactionQueueManager(
#check_interval=0.1,
max_jobs_completed=20
)
task.cleanup_db_jobs()
scheduler.add_single_task(task, mode='threaded', delay=1)
# important to close connection after adding tasks
DbContainer.close_all()
示例3: start
# 需要导入模块: from pyasm.search import DbContainer [as 别名]
# 或者: from pyasm.search.DbContainer import close_all [as 别名]
def start(cls):
task = WatchServerFolderTask()
scheduler = Scheduler.get()
scheduler.add_single_task(task, 3)
#scheduler.add_interval_task(task, 1)
scheduler.start_thread()
# important to close connection after adding tasks
DbContainer.close_all()
return scheduler
示例4: execute
# 需要导入模块: from pyasm.search import DbContainer [as 别名]
# 或者: from pyasm.search.DbContainer import close_all [as 别名]
def execute(self):
start = time.time()
#Batch()
#print "refresh caches ..."
caches = CacheContainer.get_all_caches()
for key, cache in caches.items():
#print "... %s" % key, cache
cache.init_cache()
#print "... %s seconds" % (time.time() - start)
DbContainer.commit_thread_sql()
DbContainer.close_all()
示例5: execute
# 需要导入模块: from pyasm.search import DbContainer [as 别名]
# 或者: from pyasm.search.DbContainer import close_all [as 别名]
def execute(my):
#Batch()
dirty_caches = CacheContainer.get_dirty()
for dirty_cache in dirty_caches:
key = dirty_cache.get_value("key")
#print "... caching: ", key
cache = CacheContainer.get(key)
if not cache:
print "WARNING: cache [%s] does not exist in memory" % key
continue
cache.init_cache()
DbContainer.commit_thread_sql()
DbContainer.close_all()
示例6: execute
# 需要导入模块: from pyasm.search import DbContainer [as 别名]
# 或者: from pyasm.search.DbContainer import close_all [as 别名]
def execute(my):
Batch()
# get all of the file servers
search = Search("sthpw/sync_server")
search.add_filter("state", "online")
search.add_filter("sync_mode", "file")
my.servers = search.get_sobjects()
my.tasks = []
for server in my.servers:
base_dir = server.get_value("base_dir")
if not base_dir:
continue
transaction_dir = "%s/transactions" % base_dir
ticket = server.get_value("ticket")
task = WatchFolderTask(base_dir=transaction_dir, ticket=ticket)
my.tasks.append(task)
# close all the database connections
DbContainer.close_all()
count = 0
while 1:
#start = time.time()
for task in my.tasks:
try:
task.execute()
except Exception, e:
print "WARNING: error executing task:"
print "Reported Error: ", str(e)
#print time.time() - start
# catch a breather?
time.sleep(2)
count += 1
示例7: __del__
# 需要导入模块: from pyasm.search import DbContainer [as 别名]
# 或者: from pyasm.search.DbContainer import close_all [as 别名]
def __del__(self):
# ensure that database connections are always closed
if DbContainer:
DbContainer.close_all()
示例8: execute
# 需要导入模块: from pyasm.search import DbContainer [as 别名]
# 或者: from pyasm.search.DbContainer import close_all [as 别名]
my.index = kwargs.get("index")
my.project_code = kwargs.get("project_code")
def execute(my):
try:
#Batch()
#Command.execute_cmd(timed_trigger)
Project.set_project(my.project_code)
timed_triggers[my.index].execute()
except Exception, e:
print "Error running trigger"
raise
finally:
DbContainer.close_thread_sql()
DbContainer.commit_thread_sql()
DbContainer.close_all()
for idx, timed_trigger in enumerate(timed_triggers):
data = timed_trigger.get_input()
if not data:
continue
"""
data = {
'type': 'interval',
'interval': 10,
'delay': 0,
'mode': 'threaded'
}
示例9: execute
# 需要导入模块: from pyasm.search import DbContainer [as 别名]
# 或者: from pyasm.search.DbContainer import close_all [as 别名]
def execute(self):
self.buffer = cStringIO.StringIO()
error = None
try:
try:
# clear the main container for this thread
Container.create()
# clear the buffer
WebContainer.clear_buffer()
# initialize the web environment object and register it
adapter = self.get_adapter()
WebContainer.set_web(adapter)
# get the display
self._get_display()
except SetupException as e:
'''Display setup exception in the interface'''
print("Setup exception: ", e.__str__())
DbContainer.rollback_all()
ExceptionLog.log(e)
self.writeln("<h3>Tactic Setup Error</h3>" )
self.writeln("<pre>" )
self.writeln(e.__str__() )
self.writeln("</pre>" )
error = "405: TACTIC Setup Error"
except DatabaseException as e:
from tactic.ui.startup import DbConfigPanelWdg
config_wdg = DbConfigPanelWdg()
self.writeln("<pre>")
self.writeln(config_wdg.get_buffer_display())
self.writeln("</pre>")
error = "405: TACTIC Database Error"
except Exception as e:
stack_trace = ExceptionLog.get_stack_trace(e)
#print(stack_trace)
self.writeln("<pre>")
self.writeln(stack_trace)
self.writeln("</pre>")
error = "405 %s" % str(e)
# it is possible that the security object was not set
security = Environment.get_security()
if not security:
security = Security()
WebContainer.set_security(security)
log = None
# ensure that database connections are rolled back
try:
DbContainer.rollback_all()
except Exception as e2:
print("Error: Could not rollback: ", e2.__str__())
self.writeln("Error: Could not rollback: '%s'" % e2.__str__() )
stack_trace = ExceptionLog.get_stack_trace(e2)
print(stack_trace)
self.writeln("<pre>")
self.writeln(stack_trace)
self.writeln("</pre>")
raise e
#return
try:
# WARNING: if this call causes an exception, the error
# will be obscure
log = ExceptionLog.log(e)
except Exception as e2:
print("Error: Could not log exception: ", e2.__str__())
self.writeln("Error '%s': Could not log exception" % e2.__str__() )
stack_trace = ExceptionLog.get_stack_trace(e2)
print(stack_trace)
self.writeln("<pre>")
self.writeln(stack_trace)
self.writeln("</pre>")
return
self.writeln("<pre>")
self.writeln("An Error has occurred. Please see your Tactic Administrator<br/>")
self.writeln( "Error Message: %s" % log.get_value("message") )
self.writeln("Error Id: %s" % log.get_id() )
#self.writeln( log.get_value("stack_trace") )
self.writeln("</pre>")
finally:
# ensure that database connections are always closed
DbContainer.close_all()
# clear the container
Container.delete()
WebContainer.get_buffer().write( self.buffer.getvalue() )
#.........这里部分代码省略.........