Skip to content

Commit 0a5b947

Browse files
committed
Spelling / reorg
1 parent 81b06c7 commit 0a5b947

File tree

1 file changed

+23
-23
lines changed

1 file changed

+23
-23
lines changed

xarray/backends/file_manager.py

+23-23
Original file line numberDiff line numberDiff line change
@@ -36,27 +36,6 @@ def close(self, needs_lock=True):
3636
raise NotImplementedError
3737

3838

39-
class _RefCounter(object):
40-
"""Class for keeping track of reference counts."""
41-
def __init__(self, counts):
42-
self._counts = counts
43-
self._lock = threading.Lock()
44-
45-
def increment(self, name):
46-
with self._lock:
47-
count = self._counts[name] = self._counts.get(name, 0) + 1
48-
return count
49-
50-
def decrement(self, name):
51-
with self._lock:
52-
count = self._counts[name] - 1
53-
if count:
54-
self._counts[name] = count
55-
else:
56-
del self._counts[name]
57-
return count
58-
59-
6039
class CachingFileManager(FileManager):
6140
"""Wrapper for automatically opening and closing file objects.
6241
@@ -240,8 +219,8 @@ def __del__(self):
240219

241220
def __getstate__(self):
242221
"""State for pickling."""
243-
# cache and ref_counts are intentionally omited: we don't want to try
244-
# to serailize these objects.
222+
# cache and ref_counts are intentionally omitted: we don't want to try
223+
# to serialize these global objects.
245224
lock = None if self._default_lock else self._lock
246225
return (self._opener, self._args, self._mode, self._kwargs, lock)
247226

@@ -258,6 +237,27 @@ def __repr__(self):
258237
type(self).__name__, self._opener, args_string, self._kwargs)
259238

260239

240+
class _RefCounter(object):
241+
"""Class for keeping track of reference counts."""
242+
def __init__(self, counts):
243+
self._counts = counts
244+
self._lock = threading.Lock()
245+
246+
def increment(self, name):
247+
with self._lock:
248+
count = self._counts[name] = self._counts.get(name, 0) + 1
249+
return count
250+
251+
def decrement(self, name):
252+
with self._lock:
253+
count = self._counts[name] - 1
254+
if count:
255+
self._counts[name] = count
256+
else:
257+
del self._counts[name]
258+
return count
259+
260+
261261
class _HashedSequence(list):
262262
"""Speedup repeated look-ups by caching hash values.
263263

0 commit comments

Comments
 (0)