mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-04-25 08:46:22 +02:00
feat: enhance Google Drive client with improved logging and thread-safe operations
- Added logging to track the start and end of file download and export processes, improving visibility into execution time. - Implemented per-thread HTTP transport for concurrent downloads and exports, ensuring thread safety. - Refactored download and export methods to utilize resolved credentials, enhancing functionality. - Updated unit tests to validate the new threading and logging features, ensuring robust parallel execution.
This commit is contained in:
parent
d2a4b238d7
commit
00934ff462
4 changed files with 65 additions and 8 deletions
|
|
@ -605,12 +605,13 @@ async def test_client_download_file_runs_in_thread_parallel():
|
|||
BLOCK_SECONDS = 0.2
|
||||
NUM_CALLS = 3
|
||||
|
||||
def _blocking_download(service, file_id):
|
||||
def _blocking_download(service, file_id, credentials):
|
||||
time.sleep(BLOCK_SECONDS)
|
||||
return b"fake-content", None
|
||||
|
||||
client = GoogleDriveClient.__new__(GoogleDriveClient)
|
||||
client.service = MagicMock()
|
||||
client._resolved_credentials = MagicMock()
|
||||
client._service_lock = asyncio.Lock()
|
||||
|
||||
with patch.object(
|
||||
|
|
@ -640,12 +641,13 @@ async def test_client_export_google_file_runs_in_thread_parallel():
|
|||
BLOCK_SECONDS = 0.2
|
||||
NUM_CALLS = 3
|
||||
|
||||
def _blocking_export(service, file_id, mime_type):
|
||||
def _blocking_export(service, file_id, mime_type, credentials):
|
||||
time.sleep(BLOCK_SECONDS)
|
||||
return b"exported", None
|
||||
|
||||
client = GoogleDriveClient.__new__(GoogleDriveClient)
|
||||
client.service = MagicMock()
|
||||
client._resolved_credentials = MagicMock()
|
||||
client._service_lock = asyncio.Lock()
|
||||
|
||||
with patch.object(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue