jack 1 vecka sedan
förälder
incheckning
58c88e0647
2 ändrade filer med 15 tillägg och 11 borttagningar
  1. 1 1
      app/libs/thread_executor.py
  2. 14 10
      app/providers/r2r.py

+ 1 - 1
app/libs/thread_executor.py

@@ -63,7 +63,7 @@ def run_with_executor(executor: Executor, func, tasks: List, timeout: int):
             results.append(result)
         except Exception as e:
             print(e)
-    executor.shutdown()
+    # executor.shutdown()
     return results
 
     """

+ 14 - 10
app/providers/r2r.py

@@ -18,22 +18,24 @@ class R2R:
         self.auth_enabled = tool_settings.R2R_USERNAME and tool_settings.R2R_PASSWORD
         # self.client = R2RAsyncClient(tool_settings.R2R_BASE_URL)
         # self.client_sync = R2RClient(tool_settings.R2R_BASE_URL)
-        self.client = None
-        self.client_sync = None
+        self.client = R2RAsyncClient(tool_settings.R2R_BASE_URL)
+        self.client_sync = R2RClient(tool_settings.R2R_BASE_URL)
 
     def init_sync(self):
         if not self.auth_enabled:
             return
         # if not self.client_sync:
-        client_sync = R2RClient(tool_settings.R2R_BASE_URL)
-        client_sync.users.login(tool_settings.R2R_USERNAME, tool_settings.R2R_PASSWORD)
+        # client_sync = R2RClient(tool_settings.R2R_BASE_URL)
+        self.client_sync.users.login(
+            tool_settings.R2R_USERNAME, tool_settings.R2R_PASSWORD
+        )
         print(
             "1111111111111111111111111111111122222vvdgdfdf" + tool_settings.R2R_USERNAME
         )
         # print(tool_settings.R2R_USERNAME)
         # print(tool_settings.R2R_PASSWORD)
-        print(client_sync)
-        return client_sync
+        print(self.client_sync)
+        return self.client_sync
 
     async def init(self):
         if not self.auth_enabled:
@@ -44,10 +46,12 @@ class R2R:
         )
         print(tool_settings.R2R_USERNAME)
         print(tool_settings.R2R_PASSWORD)
-        client = R2RAsyncClient(tool_settings.R2R_BASE_URL)
-        await client.users.login(tool_settings.R2R_USERNAME, tool_settings.R2R_PASSWORD)
-        print(client.access_token)
-        return client
+        # client = R2RAsyncClient(tool_settings.R2R_BASE_URL)
+        await self.client.users.login(
+            tool_settings.R2R_USERNAME, tool_settings.R2R_PASSWORD
+        )
+        print(self.client.access_token)
+        return self.client
 
     async def ingest_file(self, file_path: str, metadata: Optional[dict]):
         client = await self._check_login()