Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(python): makes RedisConnection's close method async, use aclose when possible #2559

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions python/bullmq/flow_producer.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,8 @@ async def addBulk(self, flows: list[dict]):

return result

def close(self):
async def close(self):
"""
Close the flow instance.
"""
return self.redisConnection.close()
await self.redisConnection.close()
4 changes: 2 additions & 2 deletions python/bullmq/queue.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,11 +308,11 @@ def sanitizeJobTypes(self, types):
'waiting-children'
]

def close(self):
async def close(self):
"""
Close the queue instance.
"""
return self.redisConnection.close()
await self.redisConnection.close()

def remove(self, job_id: str, opts: dict = {}):
return self.scripts.remove(job_id, opts.get("removeChildren", True))
7 changes: 5 additions & 2 deletions python/bullmq/redis_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,14 @@ def disconnect(self):
"""
return self.conn.disconnect()

def close(self):
async def close(self):
"""
Close the connection
"""
return self.conn.close()
try:
await self.conn.aclose()
except AttributeError:
await self.conn.close()

async def getRedisVersion(self):
if self.version is not None:
Expand Down