Skip to content

Commit

Permalink
rm threadpool exec
Browse files Browse the repository at this point in the history
  • Loading branch information
ssssarah committed Sep 3, 2024
1 parent fb64702 commit 2d476e4
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions kgforge/specializations/stores/nexus/batch_request_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,11 @@
from collections import namedtuple
import json
import asyncio
import concurrent.futures
from concurrent.futures import ThreadPoolExecutor

from typing import Callable, Dict, List, Optional, Tuple, Type, Any, Coroutine

from kgforge.core.commons.constants import DEFAULT_REQUEST_TIMEOUT

import aiohttp
from typing_extensions import Unpack

from aiohttp import ClientSession, ClientTimeout
Expand Down Expand Up @@ -139,15 +136,13 @@ def create_tasks_and_sessions(loop, elements, fc, callback=None):
sessions.append(session)

for res in batch_i:
# result = fc(res, client_session=session)
# prepared_request: asyncio.Task = loop.create_task(result)
result = fc(res, client_session=session)
prepared_request: asyncio.Task = loop.create_task(result)

with ThreadPoolExecutor() as executor:
prepared_request: asyncio.Task = loop.run_in_executor(executor, fc, res, session)
if callback:
prepared_request.add_done_callback(callback)
if callback:
prepared_request.add_done_callback(callback)

tasks.append(prepared_request)
tasks.append(prepared_request)

return tasks, sessions

0 comments on commit 2d476e4

Please sign in to comment.