本文整理汇总了Python中storm.tracer.trace函数的典型用法代码示例。如果您正苦于以下问题:Python trace函数的具体用法?Python trace怎么用?Python trace使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了trace函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: execute
def execute(self, async_conn):
"""Executes a query within an asyncronous psycopg2 connection
"""
if self.status == self.STATUS_CANCELLED:
return
self.status = self.STATUS_EXECUTING
# Async variant of Connection.execute() in storm/database.py
state = State()
statement = compile(self.expr, state)
stmt = convert_param_marks(statement, "?", "%s")
self._async_cursor = async_conn.cursor()
self._async_conn = async_conn
# This is postgres specific, see storm/databases/postgres.py
self._statement = stmt.encode('utf-8')
self._parameters = tuple(Connection.to_database(state.parameters))
trace("connection_raw_execute", self._conn,
self._async_cursor, self._statement, self._parameters)
self._async_cursor.execute(self._statement,
self._parameters)
# This can happen if another thread cancelled this while the cursor was
# executing. In that case, it is not interested in the retval anymore
if self.status == self.STATUS_CANCELLED:
return
self.status = self.STATUS_FINISHED
glib.idle_add(self._on_finish)
开发者ID:adrianoaguiar,项目名称:stoq,代码行数:31,代码来源:queryexecuter.py
示例2: finish
def finish(self):
"""This can only be called when the ``finish``` signal has
been emitted.
:returns: the result, which might be an object or a list depending
on self.operation_type
"""
trace("connection_raw_execute_success", self._conn,
self._async_cursor, self._statement, self._parameters)
result = self._conn.result_factory(self._conn,
self._async_cursor)
if self.operation_type == AsyncQueryOperation.GET_ALL:
# ResultSet.__iter__()
retval = []
for values in result:
obj = self.resultset._load_objects(result, values)
retval.append(obj)
elif self.operation_type == AsyncQueryOperation.GET_ONE:
# ResultSet.one()
values = result.get_one()
retval = self.resultset._load_objects(result, values)
else:
raise NotImplementedError(self.operation_type)
return retval
开发者ID:amaurihamasu,项目名称:stoq,代码行数:26,代码来源:queryexecuter.py
示例3: commit
def commit(self, close=False):
"""Commits a database.
This needs to be done to submit the actually inserts to the database.
:param close: If ``True``, the store will also be closed after committed.
"""
self._check_obsolete()
self._committing = True
# the cache will be cleared when commiting, so store them here
# and autoreload them after commit
touched_objs = []
for obj_info in self._cache.get_cached():
obj = obj_info.get_obj()
if obj is not None:
touched_objs.append(obj)
super(StoqlibStore, self).commit()
trace('transaction_commit', self)
self._pending_count = [0]
self._savepoints = []
# Reload objects on all other opened stores
for obj in touched_objs:
autoreload_object(obj)
if close:
self.close()
self._committing = False
开发者ID:adrianoaguiar,项目名称:stoq,代码行数:31,代码来源:runtime.py
示例4: close
def close(self):
"""Close the store.
Closes the socket that represents that database connection, this needs to
be called when you finished using the store.
"""
trace("transaction_close", self)
self._check_obsolete()
super(StoqlibStore, self).close()
self.obsolete = True
开发者ID:rg3915,项目名称:stoq,代码行数:11,代码来源:runtime.py
示例5: commit
def commit(self, close=False):
"""Commits a database.
This needs to be done to submit the actually inserts to the database.
:param close: If ``True``, the store will also be closed after committed.
"""
self._check_obsolete()
self._process_pending_objs()
super(StoqlibStore, self).commit()
trace("transaction_commit", self)
if close:
self.close()
开发者ID:rg3915,项目名称:stoq,代码行数:13,代码来源:runtime.py
示例6: get_result
def get_result(self):
"""Get operation result.
Note that this can only be called when the *finish* signal
has been emitted.
:returns: a :class:`AsyncResultSet` containing the result
"""
assert self.status == self.STATUS_FINISHED
trace("connection_raw_execute_success", self._conn,
self._async_cursor, self._statement, self._parameters)
result = self._conn.result_factory(self._conn,
self._async_cursor)
return AsyncResultSet(self.resultset, result)
开发者ID:adrianoaguiar,项目名称:stoq,代码行数:16,代码来源:queryexecuter.py
示例7: execute
def execute(self, async_conn):
"""Executes a query within an asyncronous psycopg2 connection
"""
# Async variant of Connection.execute() in storm/database.py
state = State()
statement = compile(self.expr, state)
stmt = convert_param_marks(statement, "?", "%s")
self._async_cursor = async_conn.cursor()
self._async_conn = async_conn
# This is postgres specific, see storm/databases/postgres.py
self._statement = stmt.encode("utf-8")
self._parameters = tuple(Connection.to_database(state.parameters))
trace("connection_raw_execute", self._conn, self._async_cursor, self._statement, self._parameters)
self._async_cursor.execute(self._statement, self._parameters)
开发者ID:rg3915,项目名称:stoq,代码行数:17,代码来源:queryexecuter.py
示例8: __init__
def __init__(self, database=None, cache=None):
"""
Creates a new store
:param database: the database to connect to or ``None``
:param cache: storm cache to use or ``None``
"""
self._savepoints = []
self.retval = None
self.needs_retval = False
self.obsolete = False
if database is None:
database = get_default_store().get_database()
Store.__init__(self, database=database, cache=cache)
_stores.add(self)
trace('transaction_create', self)
self._reset_pending_objs()
开发者ID:romaia,项目名称:stoq,代码行数:18,代码来源:runtime.py
示例9: __init__
def __init__(self, database=None, cache=None):
"""
Creates a new store
:param database: the database to connect to or ``None``
:param cache: storm cache to use or ``None``
"""
self._savepoints = []
self.retval = None
self.needs_retval = False
self.obsolete = False
if database is None:
database = get_default_store().get_database()
Store.__init__(self, database=database, cache=cache)
# FIXME: Use weakref.WeakSet when we can depend on Python 2.7
_stores[self] = None
trace("transaction_create", self)
self._reset_pending_objs()
开发者ID:rg3915,项目名称:stoq,代码行数:19,代码来源:runtime.py
示例10: __init__
def __init__(self, database=None, cache=None):
"""
Creates a new store
:param database: the database to connect to or ``None``
:param cache: storm cache to use or ``None``
"""
self._committing = False
self._savepoints = []
self._pending_count = [0]
self.retval = True
self.obsolete = False
if database is None:
database = get_default_store().get_database()
Store.__init__(self, database=database, cache=cache)
_stores.add(self)
trace('transaction_create', self)
self._setup_application_name()
开发者ID:adrianoaguiar,项目名称:stoq,代码行数:19,代码来源:runtime.py
示例11: __init__
def __init__(self, database=None, cache=None):
"""
Creates a new store
:param database: the database to connect to or ``None``
:param cache: storm cache to use or ``None``
"""
self._committing = False
self._savepoints = []
# When using savepoints, this stack will hold what objects were changed
# (created, deleted or edited) inside that savepoint.
self._dirties = [[]]
self.retval = True
self.obsolete = False
if database is None:
database = get_default_store().get_database()
Store.__init__(self, database=database, cache=cache)
_stores.add(self)
trace('transaction_create', self)
self._setup_application_name()
开发者ID:hackedbellini,项目名称:stoq,代码行数:21,代码来源:runtime.py
示例12: raw_execute
def raw_execute(self, statement, params=None):
"""Execute a raw statement with the given parameters.
It's acceptable to override this method in subclasses, but it
is not intended to be called externally.
If the global C{DEBUG} is True, the statement will be printed
to standard out.
@return: The dbapi cursor object, as fetched from L{build_raw_cursor}.
"""
raw_cursor = self.build_raw_cursor()
trace("connection_raw_execute", self, raw_cursor,
statement, params or ())
if params:
args = (statement, tuple(self.to_database(params)))
else:
args = (statement,)
try:
self._check_disconnect(raw_cursor.execute, *args)
except Exception, error:
trace("connection_raw_execute_error", self, raw_cursor,
statement, params or (), error)
raise
开发者ID:arizzi,项目名称:cms-pixel-db-pisa,代码行数:24,代码来源:database.py
示例13: test_trace
def test_trace(self):
stash = []
class Tracer(object):
def m1(_, *args, **kwargs):
stash.extend(["m1", args, kwargs])
def m2(_, *args, **kwargs):
stash.extend(["m2", args, kwargs])
install_tracer(Tracer())
trace("m1", 1, 2, c=3)
trace("m2")
trace("m3")
self.assertEquals(stash, ["m1", (1, 2), {"c": 3}, "m2", (), {}])
开发者ID:datnguyen0606,项目名称:storm,代码行数:13,代码来源:tracer.py
示例14: test_capture_multiple
def test_capture_multiple(self):
"""L{CaptureTracer}s can be used as nested context managers."""
conn = StubConnection()
def trace(statement):
for tracer in get_tracers():
tracer.connection_raw_execute(conn, "cursor", statement, [])
with CaptureTracer() as tracer1:
trace("one")
with CaptureTracer() as tracer2:
trace("two")
trace("three")
self.assertEqual([], get_tracers())
self.assertEqual(["one", "two", "three"], tracer1.queries)
self.assertEqual(["two"], tracer2.queries)
开发者ID:petrhosek,项目名称:storm,代码行数:18,代码来源:tracer.py
示例15: trace
"""
raw_cursor = self.build_raw_cursor()
trace("connection_raw_execute", self, raw_cursor,
statement, params or ())
if params:
args = (statement, tuple(self.to_database(params)))
else:
args = (statement,)
try:
self._check_disconnect(raw_cursor.execute, *args)
except Exception, error:
trace("connection_raw_execute_error", self, raw_cursor,
statement, params or (), error)
raise
else:
trace("connection_raw_execute_success", self, raw_cursor,
statement, params or ())
return raw_cursor
def _ensure_connected(self):
"""Ensure that we are connected to the database.
If the connection is marked as dead, or if we can't reconnect,
then raise DisconnectionError.
"""
if self._state == STATE_CONNECTED:
return
elif self._state == STATE_DISCONNECTED:
raise DisconnectionError("Already disconnected")
elif self._state == STATE_RECONNECT:
try:
self._raw_connection = self._database.raw_connect()
开发者ID:arizzi,项目名称:cms-pixel-db-pisa,代码行数:32,代码来源:database.py
注:本文中的storm.tracer.trace函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论