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

Proposed by Robert Collins on 2010-09-07
Status: Rejected
Rejected by: Robert Collins on 2012-04-03
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 2010-09-07 Needs Fixing on 2010-09-08
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.
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.

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 on 2010-09-07

Trace all raw cursor fetches.

376. By Robert Collins on 2010-09-07

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

375. By Robert Collins on 2010-09-07

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
1=== modified file 'storm/database.py'
2--- storm/database.py 2010-04-16 07:14:25 +0000
3+++ storm/database.py 2010-09-07 03:02:38 +0000
4@@ -82,7 +82,11 @@
5
6 @return: A converted row or None, if no data is left.
7 """
8- row = self._connection._check_disconnect(self._raw_cursor.fetchone)
9+ trace("raw_cursor_fetchone_before", self)
10+ try:
11+ row = self._connection._check_disconnect(self._raw_cursor.fetchone)
12+ finally:
13+ trace("raw_cursor_fetchone_after", self)
14 if row is not None:
15 return tuple(self.from_database(row))
16 return None
17@@ -96,7 +100,12 @@
18 @raise DisconnectionError: Raised when the connection is lost.
19 Reconnection happens automatically on rollback.
20 """
21- result = self._connection._check_disconnect(self._raw_cursor.fetchall)
22+ trace("raw_cursor_fetchall_before", self)
23+ try:
24+ result = self._connection._check_disconnect(
25+ self._raw_cursor.fetchall)
26+ finally:
27+ trace("raw_cursor_fetchall_after", self)
28 if result:
29 return [tuple(self.from_database(row)) for row in result]
30 return result
31@@ -111,8 +120,12 @@
32 Reconnection happens automatically on rollback.
33 """
34 while True:
35- results = self._connection._check_disconnect(
36- self._raw_cursor.fetchmany)
37+ trace("raw_cursor_fetchmany_before", self)
38+ try:
39+ results = self._connection._check_disconnect(
40+ self._raw_cursor.fetchmany)
41+ finally:
42+ trace("raw_cursor_fetchmany_after", self)
43 if not results:
44 break
45 for result in results:
46
47=== modified file 'storm/tracer.py'
48--- storm/tracer.py 2010-08-15 18:34:41 +0000
49+++ storm/tracer.py 2010-09-07 03:02:38 +0000
50@@ -107,10 +107,11 @@
51 _tracers = []
52
53 def trace(name, *args, **kwargs):
54- for tracer in _tracers:
55- attr = getattr(tracer, name, None)
56- if attr:
57- attr(*args, **kwargs)
58+ if _tracers:
59+ for tracer in _tracers:
60+ attr = getattr(tracer, name, None)
61+ if attr:
62+ attr(*args, **kwargs)
63
64 def install_tracer(tracer):
65 _tracers.append(tracer)

Subscribers

People subscribed via source and target branches

to status/vote changes: