Skip to content

Commit 7ade392

Browse files
committed
refactor: remove backport of 'atexit.unregister'
1 parent e05b50a commit 7ade392

File tree

5 files changed

+10
-81
lines changed

5 files changed

+10
-81
lines changed

kazoo/handlers/eventlet.py

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

4+
import atexit
45
import contextlib
56
import logging
67

@@ -12,7 +13,6 @@
1213
from eventlet import queue as green_queue
1314

1415
from kazoo.handlers import utils
15-
import kazoo.python2atexit as python2atexit
1616
from kazoo.handlers.utils import selector_select
1717

1818
LOG = logging.getLogger(__name__)
@@ -140,15 +140,15 @@ def start(self):
140140
w = eventlet.spawn(self._process_callback_queue)
141141
self._workers.append((w, self.callback_queue))
142142
self._started = True
143-
python2atexit.register(self.stop)
143+
atexit.register(self.stop)
144144

145145
def stop(self):
146146
while self._workers:
147147
w, q = self._workers.pop()
148148
q.put(_STOP)
149149
w.wait()
150150
self._started = False
151-
python2atexit.unregister(self.stop)
151+
atexit.unregister(self.stop)
152152

153153
def socket(self, *args, **kwargs):
154154
return utils.create_tcp_socket(green_socket)

kazoo/handlers/gevent.py

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

4+
import atexit
45
import logging
56

67
import gevent
@@ -19,7 +20,6 @@
1920
from gevent.coros import Semaphore, RLock
2021

2122
from kazoo.handlers import utils
22-
from kazoo import python2atexit
2323

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

@@ -104,7 +104,7 @@ def start(self):
104104
for queue in (self.callback_queue,):
105105
w = self._create_greenlet_worker(queue)
106106
self._workers.append(w)
107-
python2atexit.register(self.stop)
107+
atexit.register(self.stop)
108108

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

127-
python2atexit.unregister(self.stop)
127+
atexit.unregister(self.stop)
128128

129129
def select(self, *args, **kwargs):
130130
return selector_select(

kazoo/handlers/threading.py

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

15+
import atexit
1516
import logging
1617
import queue
1718
import socket
1819
import threading
1920
import time
2021

21-
import kazoo.python2atexit as python2atexit
2222
from kazoo.handlers import utils
2323
from kazoo.handlers.utils import selector_select
2424

@@ -141,7 +141,7 @@ def start(self):
141141
w = self._create_thread_worker(work_queue)
142142
self._workers.append(w)
143143
self._running = True
144-
python2atexit.register(self.stop)
144+
atexit.register(self.stop)
145145

146146
def stop(self):
147147
"""Stop the worker threads and empty all queues."""
@@ -162,7 +162,7 @@ def stop(self):
162162
# Clear the queues
163163
self.callback_queue = self.queue_impl()
164164
self.completion_queue = self.queue_impl()
165-
python2atexit.unregister(self.stop)
165+
atexit.unregister(self.stop)
166166

167167
def select(self, *args, **kwargs):
168168
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)