Skip to content

Commit

Permalink
refactor: remove backport of 'atexit.unregister'
Browse files Browse the repository at this point in the history
  • Loading branch information
a-ungurianu committed Nov 16, 2022
1 parent e05b50a commit 7ade392
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 81 deletions.
6 changes: 3 additions & 3 deletions kazoo/handlers/eventlet.py
@@ -1,6 +1,7 @@
"""A eventlet based handler."""
from __future__ import absolute_import

import atexit
import contextlib
import logging

Expand All @@ -12,7 +13,6 @@
from eventlet import queue as green_queue

from kazoo.handlers import utils
import kazoo.python2atexit as python2atexit
from kazoo.handlers.utils import selector_select

LOG = logging.getLogger(__name__)
Expand Down Expand Up @@ -140,15 +140,15 @@ def start(self):
w = eventlet.spawn(self._process_callback_queue)
self._workers.append((w, self.callback_queue))
self._started = True
python2atexit.register(self.stop)
atexit.register(self.stop)

def stop(self):
while self._workers:
w, q = self._workers.pop()
q.put(_STOP)
w.wait()
self._started = False
python2atexit.unregister(self.stop)
atexit.unregister(self.stop)

def socket(self, *args, **kwargs):
return utils.create_tcp_socket(green_socket)
Expand Down
6 changes: 3 additions & 3 deletions kazoo/handlers/gevent.py
@@ -1,6 +1,7 @@
"""A gevent based handler."""
from __future__ import absolute_import

import atexit
import logging

import gevent
Expand All @@ -19,7 +20,6 @@
from gevent.coros import Semaphore, RLock

from kazoo.handlers import utils
from kazoo import python2atexit

_using_libevent = gevent.__version__.startswith("0.")

Expand Down Expand Up @@ -104,7 +104,7 @@ def start(self):
for queue in (self.callback_queue,):
w = self._create_greenlet_worker(queue)
self._workers.append(w)
python2atexit.register(self.stop)
atexit.register(self.stop)

def stop(self):
"""Stop the greenlet workers and empty all queues."""
Expand All @@ -124,7 +124,7 @@ def stop(self):
# Clear the queues
self.callback_queue = self.queue_impl() # pragma: nocover

python2atexit.unregister(self.stop)
atexit.unregister(self.stop)

def select(self, *args, **kwargs):
return selector_select(
Expand Down
6 changes: 3 additions & 3 deletions kazoo/handlers/threading.py
Expand Up @@ -12,13 +12,13 @@
"""
from __future__ import absolute_import

import atexit
import logging
import queue
import socket
import threading
import time

import kazoo.python2atexit as python2atexit
from kazoo.handlers import utils
from kazoo.handlers.utils import selector_select

Expand Down Expand Up @@ -141,7 +141,7 @@ def start(self):
w = self._create_thread_worker(work_queue)
self._workers.append(w)
self._running = True
python2atexit.register(self.stop)
atexit.register(self.stop)

def stop(self):
"""Stop the worker threads and empty all queues."""
Expand All @@ -162,7 +162,7 @@ def stop(self):
# Clear the queues
self.callback_queue = self.queue_impl()
self.completion_queue = self.queue_impl()
python2atexit.unregister(self.stop)
atexit.unregister(self.stop)

def select(self, *args, **kwargs):
return selector_select(*args, **kwargs)
Expand Down
71 changes: 0 additions & 71 deletions kazoo/python2atexit.py

This file was deleted.

2 changes: 1 addition & 1 deletion kazoo/testing/harness.py
@@ -1,10 +1,10 @@
"""Kazoo testing harnesses"""
import atexit
import logging
import os
import uuid
import unittest

from kazoo import python2atexit as atexit
from kazoo.client import KazooClient
from kazoo.exceptions import KazooException
from kazoo.protocol.connection import _CONNECTION_DROP, _SESSION_EXPIRED
Expand Down

0 comments on commit 7ade392

Please sign in to comment.