abdibrahem commited on
Commit
f1abaf7
·
1 Parent(s): c8da929

fix aync requests

Browse files
Files changed (1) hide show
  1. main.py +15 -12
main.py CHANGED
@@ -818,18 +818,21 @@ class HealthcareChatbot:
818
  # loop.close()
819
  # except:
820
  # print(traceback.format_exc())
821
- def run_async():
822
- new_loop = asyncio.new_event_loop()
823
- asyncio.set_event_loop(new_loop)
824
- try:
825
- return new_loop.run_until_complete(self.backend_call(router_data))
826
- finally:
827
- new_loop.close()
828
-
829
- import concurrent.futures
830
- with concurrent.futures.ThreadPoolExecutor() as executor:
831
- future = executor.submit(run_async)
832
- api_response = future.result(timeout=30) # 30 second timeout
 
 
 
833
 
834
  print("🔗 API response received:", api_response)
835
 
 
818
  # loop.close()
819
  # except:
820
  # print(traceback.format_exc())
821
+ try:
822
+ def run_async():
823
+ new_loop = asyncio.new_event_loop()
824
+ asyncio.set_event_loop(new_loop)
825
+ try:
826
+ return new_loop.run_until_complete(self.backend_call(router_data))
827
+ finally:
828
+ new_loop.close()
829
+
830
+ import concurrent.futures
831
+ with concurrent.futures.ThreadPoolExecutor() as executor:
832
+ future = executor.submit(run_async)
833
+ api_response = future.result(timeout=30) # 30 second timeout
834
+ except:
835
+ print(traceback.format_exc())
836
 
837
  print("🔗 API response received:", api_response)
838