Skip to content

Commit a7b6991

Browse files
committed
(joe) code cleanliness
1 parent b44a531 commit a7b6991

File tree

4 files changed

+13
-13
lines changed

4 files changed

+13
-13
lines changed

locking/dynamolock/dynamolock.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import boto3
1010
from botocore.errorfactory import ClientError
1111

12-
from .. import BaseLock, CouldNotLockException
12+
from .. import BaseLock
1313

1414
from .heartbeater import HeartBeater
1515

@@ -143,7 +143,7 @@ def acquire(self, blocking=True, timeout=-1):
143143
while True:
144144
if not self._locked:
145145
try:
146-
retval = self.beat()
146+
self.beat() # we're relying on this to raise a clienterror on conflict
147147
self._locked = True
148148
self.heartbeater = self.get_heartbeater()
149149
self.heartbeater.start()
@@ -160,7 +160,7 @@ def acquire(self, blocking=True, timeout=-1):
160160
self._wait()
161161

162162
def _create_table(self):
163-
response = self.client.create_table(
163+
self.client.create_table(
164164
AttributeDefinitions=[
165165
{
166166
"AttributeName": "lockname",

locking/dynamolock/heartbeater.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ def __init__(self, interval=25, heartbeat=lambda: True, exit_flag=None, release=
1212
"""Construct the heartbeater thread object."""
1313
super(HeartBeater, self).__init__()
1414
assert exit_flag is not None
15-
self.daemon = True # daemon thread so that when the parent exits it will disappear (we're going to try to clean it up anyways)
16-
self.interval = interval # this is how frequently to check in
17-
self.heartbeat = heartbeat # this is the check-in function
15+
self.daemon = True # daemon thread so that when the parent exits it will disappear (we're going to try to clean it up anyways)
16+
self.interval = interval # this is how frequently to check in
17+
self.heartbeat = heartbeat # this is the check-in function
1818
self.exit_flag = exit_flag
1919
self.jitter = 0.1
2020
self.release = release

locking/filelock/filelock.py

+3-4
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,18 @@
33
import tempfile
44
import time
55

6-
from .. import BaseLock, CouldNotLockException
6+
from .. import BaseLock
77

88

99
class FileLock(BaseLock):
1010
@staticmethod
1111
def get_lockdir():
1212
try:
1313
tfdir = '/dev/shm'
14-
with tempfile.NamedTemporaryFile(dir=tfdir) as tfh:
14+
with tempfile.NamedTemporaryFile(dir=tfdir):
1515
pass
1616
return tfdir
17-
except Exception as oops:
18-
raise
17+
except Exception:
1918
return tempfile.gettempdir()
2019

2120
lockdir = get_lockdir.__func__()

locking/tests/test_locks.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
from .. import DynamoLock, FileLock, RedisLock, SocketLock
2-
import lock_tests
31
import threading
42
import time
5-
from _thread import start_new_thread, TIMEOUT_MAX
3+
from _thread import start_new_thread
4+
5+
import lock_tests
6+
from .. import DynamoLock, FileLock, RedisLock, SocketLock
67

78
RUNNING_ON_CI = True
89
# try:

0 commit comments

Comments
 (0)