Skip to content

Commit

Permalink
send boc to external service async
Browse files Browse the repository at this point in the history
  • Loading branch information
kdimentionaltree committed Oct 15, 2024
1 parent a58d9c3 commit e5ca057
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions ton-http-api/pyTON/api/api_v2/endpoints/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import random
import requests

from functools import wraps
from functools import wraps, partial
from datetime import datetime
from typing import Optional, List, Any, Union, Dict

Expand Down Expand Up @@ -460,11 +460,13 @@ async def detect_address(
return _detect_address(address)


def send_boc_to_external_endpoint(boc):
async def send_boc_to_external_endpoint(boc):
try:
endpoint = settings.webserver.boc_endpoint
logger.info(f'BOC is: "{boc}"')
res = requests.post(endpoint, json={'boc': boc}, timeout=0.5)
req = partial(requests.post, endpoint, json={'boc': boc}, timeout=0.5)
loop = asyncio.get_event_loop()
res = await loop.run_in_executor(None, req)
logger.info(f"Boc sent to external endpoint: {res}")
return res.get('ok', False)
except Exception as ee:
Expand Down

0 comments on commit e5ca057

Please sign in to comment.