wcp-library 1.5.4__tar.gz → 1.5.7__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {wcp_library-1.5.4 → wcp_library-1.5.7}/PKG-INFO +1 -1
- {wcp_library-1.5.4 → wcp_library-1.5.7}/pyproject.toml +1 -1
- wcp_library-1.5.7/wcp_library/sql/__init__.py +68 -0
- {wcp_library-1.5.4 → wcp_library-1.5.7}/wcp_library/sql/postgres.py +2 -1
- wcp_library-1.5.4/wcp_library/sql/__init__.py +0 -63
- {wcp_library-1.5.4 → wcp_library-1.5.7}/README.md +0 -0
- {wcp_library-1.5.4 → wcp_library-1.5.7}/wcp_library/__init__.py +0 -0
- {wcp_library-1.5.4 → wcp_library-1.5.7}/wcp_library/credentials/__init__.py +0 -0
- {wcp_library-1.5.4 → wcp_library-1.5.7}/wcp_library/credentials/_credential_manager_asynchronous.py +0 -0
- {wcp_library-1.5.4 → wcp_library-1.5.7}/wcp_library/credentials/_credential_manager_synchronous.py +0 -0
- {wcp_library-1.5.4 → wcp_library-1.5.7}/wcp_library/credentials/api.py +0 -0
- {wcp_library-1.5.4 → wcp_library-1.5.7}/wcp_library/credentials/ftp.py +0 -0
- {wcp_library-1.5.4 → wcp_library-1.5.7}/wcp_library/credentials/internet.py +0 -0
- {wcp_library-1.5.4 → wcp_library-1.5.7}/wcp_library/credentials/oracle.py +0 -0
- {wcp_library-1.5.4 → wcp_library-1.5.7}/wcp_library/credentials/postgres.py +0 -0
- {wcp_library-1.5.4 → wcp_library-1.5.7}/wcp_library/emailing.py +0 -0
- {wcp_library-1.5.4 → wcp_library-1.5.7}/wcp_library/ftp/__init__.py +0 -0
- {wcp_library-1.5.4 → wcp_library-1.5.7}/wcp_library/ftp/ftp.py +0 -0
- {wcp_library-1.5.4 → wcp_library-1.5.7}/wcp_library/ftp/sftp.py +0 -0
- {wcp_library-1.5.4 → wcp_library-1.5.7}/wcp_library/informatica.py +0 -0
- {wcp_library-1.5.4 → wcp_library-1.5.7}/wcp_library/logging.py +0 -0
- {wcp_library-1.5.4 → wcp_library-1.5.7}/wcp_library/selenium/__init__.py +0 -0
- {wcp_library-1.5.4 → wcp_library-1.5.7}/wcp_library/selenium/_selenium_driver.py +0 -0
- {wcp_library-1.5.4 → wcp_library-1.5.7}/wcp_library/selenium/selenium_helper.py +0 -0
- {wcp_library-1.5.4 → wcp_library-1.5.7}/wcp_library/sql/oracle.py +0 -0
- {wcp_library-1.5.4 → wcp_library-1.5.7}/wcp_library/time.py +0 -0
@@ -0,0 +1,68 @@
|
|
1
|
+
import asyncio
|
2
|
+
import logging
|
3
|
+
from functools import wraps
|
4
|
+
from time import sleep
|
5
|
+
|
6
|
+
import oracledb
|
7
|
+
import psycopg
|
8
|
+
|
9
|
+
logger = logging.getLogger(__name__)
|
10
|
+
|
11
|
+
|
12
|
+
def retry(f: callable) -> callable:
|
13
|
+
"""
|
14
|
+
Decorator to retry a function
|
15
|
+
|
16
|
+
:param f: function
|
17
|
+
:return: function
|
18
|
+
"""
|
19
|
+
|
20
|
+
@wraps(f)
|
21
|
+
def wrapper(self, *args, **kwargs):
|
22
|
+
self._retry_count = 0
|
23
|
+
while True:
|
24
|
+
try:
|
25
|
+
return f(self, *args, **kwargs)
|
26
|
+
except (oracledb.OperationalError, oracledb.DatabaseError, psycopg.OperationalError) as e:
|
27
|
+
if isinstance(e, (oracledb.OperationalError, oracledb.DatabaseError, psycopg.OperationalError, psycopg.DatabaseError)):
|
28
|
+
error_obj, = e.args
|
29
|
+
if error_obj.full_code in self.retry_error_codes and self._retry_count < self.retry_limit:
|
30
|
+
self._retry_count += 1
|
31
|
+
logger.debug("Oracle connection error")
|
32
|
+
logger.debug(error_obj.message)
|
33
|
+
logger.info("Waiting 5 minutes before retrying Oracle connection")
|
34
|
+
sleep(300)
|
35
|
+
else:
|
36
|
+
raise e
|
37
|
+
raise e
|
38
|
+
return wrapper
|
39
|
+
|
40
|
+
|
41
|
+
def async_retry(f: callable) -> callable:
|
42
|
+
"""
|
43
|
+
Decorator to retry a function
|
44
|
+
|
45
|
+
:param f: function
|
46
|
+
:return: function
|
47
|
+
"""
|
48
|
+
|
49
|
+
@wraps(f)
|
50
|
+
async def wrapper(self, *args, **kwargs):
|
51
|
+
self._retry_count = 0
|
52
|
+
while True:
|
53
|
+
try:
|
54
|
+
return await f(self, *args, **kwargs)
|
55
|
+
except (oracledb.OperationalError, oracledb.DatabaseError, psycopg.OperationalError) as e:
|
56
|
+
if isinstance(e, (oracledb.OperationalError, oracledb.DatabaseError, psycopg.OperationalError, psycopg.DatabaseError)):
|
57
|
+
error_obj, = e.args
|
58
|
+
if error_obj.full_code in self.retry_error_codes and self._retry_count < self.retry_limit:
|
59
|
+
self._retry_count += 1
|
60
|
+
logger.debug(f"{self._db_service} connection error")
|
61
|
+
logger.debug(error_obj.message)
|
62
|
+
logger.info("Waiting 5 minutes before retrying Oracle connection")
|
63
|
+
await asyncio.sleep(300)
|
64
|
+
else:
|
65
|
+
raise e
|
66
|
+
else:
|
67
|
+
raise e
|
68
|
+
return wrapper
|
@@ -62,7 +62,8 @@ async def _async_connect_warehouse(username: str, password: str, hostname: str,
|
|
62
62
|
conninfo=conninfo,
|
63
63
|
min_size=min_connections,
|
64
64
|
max_size=max_connections,
|
65
|
-
kwargs={"options": "-c datestyle=ISO,YMD"}
|
65
|
+
kwargs={"options": "-c datestyle=ISO,YMD"},
|
66
|
+
open=False
|
66
67
|
)
|
67
68
|
return session_pool
|
68
69
|
|
@@ -1,63 +0,0 @@
|
|
1
|
-
import asyncio
|
2
|
-
import logging
|
3
|
-
from functools import wraps
|
4
|
-
from time import sleep
|
5
|
-
|
6
|
-
import oracledb
|
7
|
-
import psycopg
|
8
|
-
|
9
|
-
logger = logging.getLogger(__name__)
|
10
|
-
|
11
|
-
|
12
|
-
def retry(f: callable) -> callable:
|
13
|
-
"""
|
14
|
-
Decorator to retry a function
|
15
|
-
|
16
|
-
:param f: function
|
17
|
-
:return: function
|
18
|
-
"""
|
19
|
-
|
20
|
-
@wraps(f)
|
21
|
-
def wrapper(self, *args, **kwargs):
|
22
|
-
self._retry_count = 0
|
23
|
-
while True:
|
24
|
-
try:
|
25
|
-
return f(self, *args, **kwargs)
|
26
|
-
except (oracledb.OperationalError, oracledb.DatabaseError, psycopg.OperationalError) as e:
|
27
|
-
error_obj, = e.args
|
28
|
-
if error_obj.full_code in self.retry_error_codes and self._retry_count < self.retry_limit:
|
29
|
-
self._retry_count += 1
|
30
|
-
logger.debug("Oracle connection error")
|
31
|
-
logger.debug(error_obj.message)
|
32
|
-
logger.info("Waiting 5 minutes before retrying Oracle connection")
|
33
|
-
sleep(300)
|
34
|
-
else:
|
35
|
-
raise e
|
36
|
-
return wrapper
|
37
|
-
|
38
|
-
|
39
|
-
def async_retry(f: callable) -> callable:
|
40
|
-
"""
|
41
|
-
Decorator to retry a function
|
42
|
-
|
43
|
-
:param f: function
|
44
|
-
:return: function
|
45
|
-
"""
|
46
|
-
|
47
|
-
@wraps(f)
|
48
|
-
async def wrapper(self, *args, **kwargs):
|
49
|
-
self._retry_count = 0
|
50
|
-
while True:
|
51
|
-
try:
|
52
|
-
return await f(self, *args, **kwargs)
|
53
|
-
except (oracledb.OperationalError, oracledb.DatabaseError, psycopg.OperationalError) as e:
|
54
|
-
error_obj, = e.args
|
55
|
-
if error_obj.full_code in self.retry_error_codes and self._retry_count < self.retry_limit:
|
56
|
-
self._retry_count += 1
|
57
|
-
logger.debug(f"{self._db_service} connection error")
|
58
|
-
logger.debug(error_obj.message)
|
59
|
-
logger.info("Waiting 5 minutes before retrying Oracle connection")
|
60
|
-
await asyncio.sleep(300)
|
61
|
-
else:
|
62
|
-
raise e
|
63
|
-
return wrapper
|
File without changes
|
File without changes
|
File without changes
|
{wcp_library-1.5.4 → wcp_library-1.5.7}/wcp_library/credentials/_credential_manager_asynchronous.py
RENAMED
File without changes
|
{wcp_library-1.5.4 → wcp_library-1.5.7}/wcp_library/credentials/_credential_manager_synchronous.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|