Skip to content

Commit 1f5db17

Browse files
authored
Cache boto3 clients + remove duplicated code (#25)
1 parent 76ad78c commit 1f5db17

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

locking/config.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
11
from getpass import getuser
2-
from os import environ
2+
from os import environ, getpid
3+
import functools
34

45
import boto3
56

67

78
def get_on_ci():
89
return "semaphore" == getuser()
910

10-
1111
def get_boto3_client(service):
12+
return _get_boto3_client(getpid(), service)
13+
14+
@functools.lru_cache()
15+
def _get_boto3_client(pid, service):
1216
env_var_name = f"{service.upper()}_PORT"
1317
env_port = environ.get(env_var_name)
1418
if env_port:

locking/filelock/filelock.py

-5
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,3 @@ def release(self):
5656
fcntl.flock(fd, fcntl.LOCK_UN)
5757
self._locked = False
5858
os.close(fd)
59-
60-
if True:
61-
62-
def __del__(self):
63-
self.release()

0 commit comments

Comments
 (0)