Skip to content

Commit

Permalink
fix: subscribe tasks
Browse files Browse the repository at this point in the history
  • Loading branch information
eruizgar91 committed Dec 10, 2024
1 parent 0d8457d commit 6cade7f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
18 changes: 9 additions & 9 deletions payments_py/ai_query_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,20 +221,20 @@ async def subscribe_task_logs(self, callback: Any, tasks: List[str]):
try:
if not tasks:
raise Exception('No task rooms to join in configuration')

await self.connect_socket()
self.socket_client.on('_connected', self._on_connected(callback, tasks))
async def join_task():
await self.socket_client.emit('_join-tasks', json.dumps({'tasks': tasks}))
self.socket_client.on('_join-tasks_', self._on_connected(callback, tasks))
self.socket_client.on('_connected', await join_task())
except Exception as error:
raise Exception(f"Unable to initialize websocket client: {self.web_socket_host} - {str(error)}")


def _on_connected(self, callback: Any, tasks: List[str]):
async def handle_connected_event(*args):
print(f"connectTasksSocket:: Joining tasks: {tasks}")
await self.socket_client.emit('_join-tasks', {'tasks': tasks})

def _on_connected(self, callback: Any, tasks: List[str]):
def handle_connected_event(*args):
async def handle_task_log_event(data: Any):
callback(data)

await callback(data)
self.socket_client.on('task-log', handle_task_log_event)

return handle_connected_event
return handle_connected_event
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "payments-py"
version = "0.5.3"
version = "0.5.4"
description = ""
authors = ["enrique <enrique@nevermined.io>"]
readme = "README.md"
Expand Down

0 comments on commit 6cade7f

Please sign in to comment.