Changeset 457:3f80c4282d20
- Timestamp:
- 08/01/08 16:46:11
(5 months ago)
- Author:
- "Brian Warner <warner@lothar.com>"
- branch:
- default
- Message:
log-gatherer fix timed-rotator vs LoopingCall?(now=true)
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| r456 |
r457 |
|
| 1 | 1 | 2008-08-01 Brian Warner <warner@lothar.com> |
|---|
| | 2 | |
|---|
| | 3 | * foolscap/logging/gatherer.py (GathererService.do_rotate): oops, |
|---|
| | 4 | implement the precautions claimed by the comment in startService: |
|---|
| | 5 | test self._savefile before doing anything. |
|---|
| | 6 | (GathererService.__init__): set self._savefile to None |
|---|
| | 7 | * foolscap/test/test_logging.py (Gatherer.test_log_gatherer2): add |
|---|
| | 8 | a timed rotator, which caught the problem in do_rotate |
|---|
| 2 | 9 | |
|---|
| 3 | 10 | * foolscap/test/test_logging.py (IncidentGatherer.test_emit): add |
|---|
| r454 |
r457 |
|
| 153 | 153 | if signal and hasattr(signal, "SIGHUP"): |
|---|
| 154 | 154 | signal.signal(signal.SIGHUP, self._handle_SIGHUP) |
|---|
| | 155 | self._savefile = None |
|---|
| 155 | 156 | |
|---|
| 156 | 157 | def _handle_SIGHUP(self, *args): |
|---|
| … | … | |
| 181 | 182 | |
|---|
| 182 | 183 | def do_rotate(self): |
|---|
| | 184 | if not self._savefile: |
|---|
| | 185 | return |
|---|
| 183 | 186 | self._savefile.close() |
|---|
| 184 | 187 | now = time.time() |
|---|
| r456 |
r457 |
|
| 1156 | 1156 | |
|---|
| 1157 | 1157 | def test_log_gatherer2(self): |
|---|
| 1158 | | # set log-gatherer-furl, then setLocation |
|---|
| | 1158 | # set log-gatherer-furl, then setLocation. Also, use a timed rotator. |
|---|
| 1159 | 1159 | basedir = "logging/Gatherer/log_gatherer2" |
|---|
| 1160 | 1160 | os.makedirs(basedir) |
|---|
| 1161 | 1161 | |
|---|
| 1162 | 1162 | # create a gatherer, which will create its own Tub |
|---|
| 1163 | | gatherer = MyGatherer(None, False, basedir) |
|---|
| | 1163 | gatherer = MyGatherer(3600, False, basedir) |
|---|
| 1164 | 1164 | gatherer.tub_class = GoodEnoughTub |
|---|
| 1165 | 1165 | gatherer.d = defer.Deferred() |
|---|