File tree Expand file tree Collapse file tree 1 file changed +5
-7
lines changed Expand file tree Collapse file tree 1 file changed +5
-7
lines changed Original file line number Diff line number Diff line change @@ -78,15 +78,14 @@ def __init__(
78
78
79
79
def connect (self ) -> None :
80
80
"""
81
- Establish a connection to Postgres.
82
- If a connection already exists, it's overwritten .
81
+ Creates a ConnectionPool and waits until a connection to Postgres is
82
+ established .
83
83
"""
84
- # if self.conn is None or self.conn.closed:
85
- # self.conn = self.get_connection()
86
- self .pool = ConnectionPool (self ._dsn , open = True , min_size = 1 )
84
+ self .pool = ConnectionPool (self ._dsn , open = True , min_size = 2 )
87
85
# This will block the use of the pool until min_size connections
88
86
# have been acquired
89
87
self .pool .wait ()
88
+ logger .info ("ConnectionPool is ready" )
90
89
91
90
def _create_queue_table (self ) -> None :
92
91
"""
@@ -439,7 +438,7 @@ def complete(self, task_id: Optional[UUID]) -> int:
439
438
if count == 0 :
440
439
logger .info (f"Task { task_id } was already completed" )
441
440
442
- conn .commit ()
441
+ conn .commit ()
443
442
return count
444
443
445
444
def is_empty (self ) -> bool :
@@ -575,7 +574,6 @@ def get_updated_expired_task(
575
574
),
576
575
)
577
576
updated_row = cur .fetchone ()
578
- conn .commit ()
579
577
if updated_row is None :
580
578
return None , None
581
579
You can’t perform that action at this time.
0 commit comments