Skip to content
This repository was archived by the owner on Sep 17, 2025. It is now read-only.

Commit 7783196

Browse files
authored
Use logging handler close instead of custom atexit (#1134)
1 parent d258dfb commit 7783196

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

contrib/opencensus-ext-azure/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
([#1127](https://github.com/census-instrumentation/opencensus-python/pull/1127))
77
- Fix failure counting statsbeat - refactor status code logic in transport
88
([#1132](https://github.com/census-instrumentation/opencensus-python/pull/1132))
9+
- Use logging handler close instead of custom atexit hook
10+
([#1134](https://github.com/census-instrumentation/opencensus-python/pull/1134))
911

1012
## 1.1.4
1113
Released 2022-04-20

contrib/opencensus-ext-azure/opencensus/ext/azure/log_exporter/__init__.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
import atexit
1615
import logging
1716
import os
1817
import random
@@ -67,7 +66,6 @@ def __init__(self, **options):
6766
self._queue = Queue(capacity=self.options.queue_capacity)
6867
self._worker = Worker(self._queue, self)
6968
self._worker.start()
70-
atexit.register(self.close, self.options.grace_period)
7169
# start statsbeat on exporter instantiation
7270
if not os.environ.get("APPLICATIONINSIGHTS_STATSBEAT_DISABLED_ALL"):
7371
statsbeat.collect_statsbeat_metrics(self.options)
@@ -96,11 +94,15 @@ def _export(self, batch, event=None): # pragma: NO COVER
9694
if event:
9795
event.set()
9896

97+
# Close is automatically called as part of logging shutdown
9998
def close(self, timeout=None):
99+
if not timeout:
100+
timeout = self.options.grace_period
100101
if self.storage:
101102
self.storage.close()
102103
if self._worker:
103104
self._worker.stop(timeout)
105+
super(BaseLogHandler, self).close()
104106

105107
def createLock(self):
106108
self.lock = None

0 commit comments

Comments
 (0)