Skip to content

Commit b6be40a

Browse files
committed
refactor: remove backport of 'atexit.unregister'
1 parent 4833bd4 commit b6be40a

File tree

5 files changed

+13
-81
lines changed

5 files changed

+13
-81
lines changed

kazoo/handlers/eventlet.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
"""A eventlet based handler."""
22
from __future__ import absolute_import
33

4+
import atexit
5+
46
import contextlib
57
import logging
68

@@ -12,7 +14,6 @@
1214
from eventlet import queue as green_queue
1315

1416
from kazoo.handlers import utils
15-
import kazoo.python2atexit as python2atexit
1617
from kazoo.handlers.utils import selector_select
1718

1819
LOG = logging.getLogger(__name__)
@@ -140,15 +141,15 @@ def start(self):
140141
w = eventlet.spawn(self._process_callback_queue)
141142
self._workers.append((w, self.callback_queue))
142143
self._started = True
143-
python2atexit.register(self.stop)
144+
atexit.register(self.stop)
144145

145146
def stop(self):
146147
while self._workers:
147148
w, q = self._workers.pop()
148149
q.put(_STOP)
149150
w.wait()
150151
self._started = False
151-
python2atexit.unregister(self.stop)
152+
atexit.unregister(self.stop)
152153

153154
def socket(self, *args, **kwargs):
154155
return utils.create_tcp_socket(green_socket)

kazoo/handlers/gevent.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
"""A gevent based handler."""
22
from __future__ import absolute_import
33

4+
import atexit
5+
46
import logging
57

68
import gevent
@@ -19,7 +21,6 @@
1921
from gevent.coros import Semaphore, RLock
2022

2123
from kazoo.handlers import utils
22-
from kazoo import python2atexit
2324

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

@@ -104,7 +105,7 @@ def start(self):
104105
for queue in (self.callback_queue,):
105106
w = self._create_greenlet_worker(queue)
106107
self._workers.append(w)
107-
python2atexit.register(self.stop)
108+
atexit.register(self.stop)
108109

109110
def stop(self):
110111
"""Stop the greenlet workers and empty all queues."""
@@ -124,7 +125,7 @@ def stop(self):
124125
# Clear the queues
125126
self.callback_queue = self.queue_impl() # pragma: nocover
126127

127-
python2atexit.unregister(self.stop)
128+
atexit.unregister(self.stop)
128129

129130
def select(self, *args, **kwargs):
130131
return selector_select(

kazoo/handlers/threading.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,13 @@
1212
"""
1313
from __future__ import absolute_import
1414

15+
import atexit
16+
1517
import logging
1618
import socket
1719
import threading
1820
import time
1921

20-
import kazoo.python2atexit as python2atexit
2122
from kazoo.handlers import utils
2223
from kazoo.handlers.utils import selector_select
2324

@@ -141,7 +142,7 @@ def start(self):
141142
w = self._create_thread_worker(work_queue)
142143
self._workers.append(w)
143144
self._running = True
144-
python2atexit.register(self.stop)
145+
atexit.register(self.stop)
145146

146147
def stop(self):
147148
"""Stop the worker threads and empty all queues."""
@@ -162,7 +163,7 @@ def stop(self):
162163
# Clear the queues
163164
self.callback_queue = self.queue_impl()
164165
self.completion_queue = self.queue_impl()
165-
python2atexit.unregister(self.stop)
166+
atexit.unregister(self.stop)
166167

167168
def select(self, *args, **kwargs):
168169
return selector_select(*args, **kwargs)

kazoo/python2atexit.py

Lines changed: 0 additions & 71 deletions
This file was deleted.

kazoo/testing/harness.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
"""Kazoo testing harnesses"""
2+
import atexit
23
import logging
34
import os
45
import uuid
56
import unittest
67

7-
from kazoo import python2atexit as atexit
88
from kazoo.client import KazooClient
99
from kazoo.exceptions import KazooException
1010
from kazoo.protocol.connection import _CONNECTION_DROP, _SESSION_EXPIRED

0 commit comments

Comments
 (0)