Skip to content

Commit

Permalink
Use logging handler close instead of custom atexit (#1134)
Browse files Browse the repository at this point in the history
  • Loading branch information
lzchen committed Jun 29, 2022
1 parent d258dfb commit 7783196
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 2 additions & 0 deletions contrib/opencensus-ext-azure/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
([#1127](https://github.com/census-instrumentation/opencensus-python/pull/1127))
- Fix failure counting statsbeat - refactor status code logic in transport
([#1132](https://github.com/census-instrumentation/opencensus-python/pull/1132))
- Use logging handler close instead of custom atexit hook
([#1134](https://github.com/census-instrumentation/opencensus-python/pull/1134))

## 1.1.4
Released 2022-04-20
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import atexit
import logging
import os
import random
Expand Down Expand Up @@ -67,7 +66,6 @@ def __init__(self, **options):
self._queue = Queue(capacity=self.options.queue_capacity)
self._worker = Worker(self._queue, self)
self._worker.start()
atexit.register(self.close, self.options.grace_period)
# start statsbeat on exporter instantiation
if not os.environ.get("APPLICATIONINSIGHTS_STATSBEAT_DISABLED_ALL"):
statsbeat.collect_statsbeat_metrics(self.options)
Expand Down Expand Up @@ -96,11 +94,15 @@ def _export(self, batch, event=None): # pragma: NO COVER
if event:
event.set()

# Close is automatically called as part of logging shutdown
def close(self, timeout=None):
if not timeout:
timeout = self.options.grace_period
if self.storage:
self.storage.close()
if self._worker:
self._worker.stop(timeout)
super(BaseLogHandler, self).close()

def createLock(self):
self.lock = None
Expand Down

0 comments on commit 7783196

Please sign in to comment.