assemblyline-service-client 4.5.1.dev92__py3-none-any.whl → 4.5.1.dev93__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of assemblyline-service-client might be problematic. Click here for more details.

@@ -1 +1 @@
1
- 4.5.1.dev92
1
+ 4.5.1.dev93
@@ -35,6 +35,7 @@ LOG_LEVEL = logging.getLevelName(os.environ.get("LOG_LEVEL", "INFO"))
35
35
  SHUTDOWN_SECONDS_LIMIT = 10
36
36
  SUPPORTED_API = 'v1'
37
37
  TASK_REQUEST_TIMEOUT = int(os.environ.get('TASK_REQUEST_TIMEOUT', 30))
38
+ FILE_REQUEST_TIMEOUT = int(os.environ.get('FILE_REQUEST_TIMEOUT', 180))
38
39
 
39
40
 
40
41
  # The number of tasks a service will complete before stopping, letting the environment start a new container.
@@ -212,7 +213,8 @@ class TaskHandler(ServerBase):
212
213
  elif retry % 10 == 0:
213
214
  self.log.warning(f"Service server has been unreachable for the past {retry} attempts. "
214
215
  "Is there something wrong with it?")
215
- except requests.Timeout: # Handles ConnectTimeout and ReadTimeout
216
+ except requests.Timeout as e: # Handles ConnectTimeout and ReadTimeout
217
+ self.log.warning(f"We've timed out on: {url} ({e}) Retrying..")
216
218
  pass
217
219
  except requests.HTTPError as e:
218
220
  self.log.error(str(e))
@@ -367,7 +369,7 @@ class TaskHandler(ServerBase):
367
369
  file_path = None
368
370
  self.log.info(f"[{sid}] Downloading file: {sha256}")
369
371
  response = self.request_with_retries('get', self._path('file', sha256),
370
- get_api_response=False, max_retry=3, headers=self.headers)
372
+ get_api_response=False, max_retry=3, headers=self.headers, timeout=FILE_REQUEST_TIMEOUT)
371
373
  if response is not None:
372
374
  # Check if we got a 'good' response
373
375
  if response.status_code == 200:
@@ -421,7 +423,7 @@ class TaskHandler(ServerBase):
421
423
 
422
424
  data = dict(task=task.as_primitives(), result=result, freshen=True)
423
425
  try:
424
- r = self.request_with_retries('post', self._path('task'), json=data)
426
+ r = self.request_with_retries('post', self._path('task'), json=data, timeout=TASK_REQUEST_TIMEOUT)
425
427
 
426
428
  if not r['success'] and r['missing_files']:
427
429
  while not r['success'] and r['missing_files']:
@@ -437,10 +439,11 @@ class TaskHandler(ServerBase):
437
439
  with open(file_info['path'], 'rb') as fh:
438
440
  # Upload the file requested by service server
439
441
  self.log.info(f"[{task.sid}] Uploading file {file_info['path']} [{file_info['sha256']}]")
440
- self.request_with_retries('put', self._path('file'), files=dict(file=fh), headers=headers)
442
+ self.request_with_retries('put', self._path('file'), files=dict(file=fh), headers=headers,
443
+ timeout=FILE_REQUEST_TIMEOUT)
441
444
 
442
445
  data['freshen'] = False
443
- r = self.request_with_retries('post', self._path('task'), json=data)
446
+ r = self.request_with_retries('post', self._path('task'), json=data, timeout=TASK_REQUEST_TIMEOUT)
444
447
  except (ServiceServerException, requests.HTTPError) as e:
445
448
  self.handle_task_error(task, message=str(e), error_type='EXCEPTION', status='FAIL_NONRECOVERABLE')
446
449
 
@@ -473,7 +476,7 @@ class TaskHandler(ServerBase):
473
476
  self.log.exception(f"[{task.sid}] An error occurred while loading service error file.")
474
477
 
475
478
  data = dict(task=task.as_primitives(), error=error)
476
- self.request_with_retries('post', self._path('task'), json=data)
479
+ self.request_with_retries('post', self._path('task'), json=data, timeout=TASK_REQUEST_TIMEOUT)
477
480
 
478
481
  def stop(self):
479
482
  if self.status == STATUSES.WAITING_FOR_TASK:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: assemblyline-service-client
3
- Version: 4.5.1.dev92
3
+ Version: 4.5.1.dev93
4
4
  Summary: Assemblyline 4 - Service client
5
5
  Home-page: https://github.com/CybercentreCanada/assemblyline-service-client/
6
6
  Author: CCCS Assemblyline development team
@@ -0,0 +1,8 @@
1
+ assemblyline_service_client/VERSION,sha256=G9pBMQfRxZ-eeKDX_TxdkLhDvwbvQLuRw3bfiEq6Zo8,12
2
+ assemblyline_service_client/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
3
+ assemblyline_service_client/task_handler.py,sha256=uJuYbd5tU1DlJXy7f0CjL0912x-Mvw1U4rOB2IiIV48,22907
4
+ assemblyline_service_client-4.5.1.dev93.dist-info/LICENCE.md,sha256=NSkYo9EH8h5oOkzg4VhjAHF4339MqPP2cQ8msTPgl-c,1396
5
+ assemblyline_service_client-4.5.1.dev93.dist-info/METADATA,sha256=ILHXAMHYhKPxUClL6Xl28hWl_9Oll6C5ntyuOCtoXNM,1577
6
+ assemblyline_service_client-4.5.1.dev93.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
7
+ assemblyline_service_client-4.5.1.dev93.dist-info/top_level.txt,sha256=clNWHvn8nw0kR15l5TASxWxIQvKGKe5Pso3kVPMiJv0,28
8
+ assemblyline_service_client-4.5.1.dev93.dist-info/RECORD,,
@@ -1,8 +0,0 @@
1
- assemblyline_service_client/VERSION,sha256=IQFQHR8oxRt7ecJ17ZA70nyaEbUx3tEgflhXtE-1Gps,12
2
- assemblyline_service_client/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
3
- assemblyline_service_client/task_handler.py,sha256=uiAOFBy-8Cylv2hwK2d3I58nPGKe1nmvtVOc0C0x1l8,22546
4
- assemblyline_service_client-4.5.1.dev92.dist-info/LICENCE.md,sha256=NSkYo9EH8h5oOkzg4VhjAHF4339MqPP2cQ8msTPgl-c,1396
5
- assemblyline_service_client-4.5.1.dev92.dist-info/METADATA,sha256=Hv6ud8ZdceTuTRpF0jIlIZl9nvN02szGB-bmt0uX6cI,1577
6
- assemblyline_service_client-4.5.1.dev92.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
7
- assemblyline_service_client-4.5.1.dev92.dist-info/top_level.txt,sha256=clNWHvn8nw0kR15l5TASxWxIQvKGKe5Pso3kVPMiJv0,28
8
- assemblyline_service_client-4.5.1.dev92.dist-info/RECORD,,