Merge lp:~lifeless/storm/bug-618019 into lp:storm

Proposed by Robert Collins
Status: Rejected
Rejected by: Robert Collins
Proposed branch: lp:~lifeless/storm/bug-618019
Merge into: lp:storm
Diff against target: 65 lines (+22/-8)
2 files modified
storm/database.py (+17/-4)
storm/tracer.py (+5/-4)
To merge this branch: bzr merge lp:~lifeless/storm/bug-618019
Reviewer Review Type Date Requested Status
Gustavo Niemeyer Needs Fixing
Review via email: mp+34715@code.launchpad.net

Description of the change

Permit instrumentation in launchpad OOPS reports of incremental DB time (which may be inconsequential, but its not AFAWCT guaranteed to be so).

To post a comment you must log in.
Revision history for this message
Robert Collins (lifeless) wrote :

Note that this has as much direct testing as I could find of the emitting-of-tracers for the rest of database.py (none :(). However its extremely simple as-is.

Revision history for this message
Gustavo Niemeyer (niemeyer) wrote :

There are tests for trace emitters. Just grep for their names under tests/* and you should find them.

Also, even if there were none, lack of prior testing isn't generally an excuse for slacking in the future.

review: Needs Fixing

Unmerged revisions

377. By Robert Collins

Trace all raw cursor fetches.

376. By Robert Collins

Trace fetchmany calls. No tests - where would they go?

375. By Robert Collins

Guard tracer iteration with if _tracers at Gustavo's request.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'storm/database.py'
--- storm/database.py 2010-04-16 07:14:25 +0000
+++ storm/database.py 2010-09-07 03:02:38 +0000
@@ -82,7 +82,11 @@
8282
83 @return: A converted row or None, if no data is left.83 @return: A converted row or None, if no data is left.
84 """84 """
85 row = self._connection._check_disconnect(self._raw_cursor.fetchone)85 trace("raw_cursor_fetchone_before", self)
86 try:
87 row = self._connection._check_disconnect(self._raw_cursor.fetchone)
88 finally:
89 trace("raw_cursor_fetchone_after", self)
86 if row is not None:90 if row is not None:
87 return tuple(self.from_database(row))91 return tuple(self.from_database(row))
88 return None92 return None
@@ -96,7 +100,12 @@
96 @raise DisconnectionError: Raised when the connection is lost.100 @raise DisconnectionError: Raised when the connection is lost.
97 Reconnection happens automatically on rollback.101 Reconnection happens automatically on rollback.
98 """102 """
99 result = self._connection._check_disconnect(self._raw_cursor.fetchall)103 trace("raw_cursor_fetchall_before", self)
104 try:
105 result = self._connection._check_disconnect(
106 self._raw_cursor.fetchall)
107 finally:
108 trace("raw_cursor_fetchall_after", self)
100 if result:109 if result:
101 return [tuple(self.from_database(row)) for row in result]110 return [tuple(self.from_database(row)) for row in result]
102 return result111 return result
@@ -111,8 +120,12 @@
111 Reconnection happens automatically on rollback.120 Reconnection happens automatically on rollback.
112 """121 """
113 while True:122 while True:
114 results = self._connection._check_disconnect(123 trace("raw_cursor_fetchmany_before", self)
115 self._raw_cursor.fetchmany)124 try:
125 results = self._connection._check_disconnect(
126 self._raw_cursor.fetchmany)
127 finally:
128 trace("raw_cursor_fetchmany_after", self)
116 if not results:129 if not results:
117 break130 break
118 for result in results:131 for result in results:
119132
=== modified file 'storm/tracer.py'
--- storm/tracer.py 2010-08-15 18:34:41 +0000
+++ storm/tracer.py 2010-09-07 03:02:38 +0000
@@ -107,10 +107,11 @@
107_tracers = []107_tracers = []
108108
109def trace(name, *args, **kwargs):109def trace(name, *args, **kwargs):
110 for tracer in _tracers:110 if _tracers:
111 attr = getattr(tracer, name, None)111 for tracer in _tracers:
112 if attr:112 attr = getattr(tracer, name, None)
113 attr(*args, **kwargs)113 if attr:
114 attr(*args, **kwargs)
114115
115def install_tracer(tracer):116def install_tracer(tracer):
116 _tracers.append(tracer)117 _tracers.append(tracer)

Subscribers

People subscribed via source and target branches

to status/vote changes: