Skip to content

Commit

Permalink
Remove all print statements
Browse files Browse the repository at this point in the history
As part of the review, move to actual logging statements rather than print statements.
  • Loading branch information
gordonwatts committed May 30, 2021
1 parent 200c253 commit a241227
Showing 1 changed file with 19 additions and 12 deletions.
31 changes: 19 additions & 12 deletions src/servicex_did_finder_lib/servicex_adaptor.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,13 @@
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
from datetime import datetime
import requests
import logging


MAX_RETRIES = 3

__logging = logging.getLogger(__name__)


class ServiceXAdapter:
def __init__(self, endpoint):
Expand All @@ -49,11 +52,12 @@ def post_status_update(self, status_msg, severity="info"):
})
success = True
except requests.exceptions.ConnectionError:
print("Connection err. Retry")
__logging.exception(f'Connection error to ServiceX App. Will retry (try {attempts}'
f' out of {MAX_RETRIES}')
attempts += 1
if not success:
print("******** Failed to write status message")
print("******** Continuing")
__logging.error(f'After {attempts} tries, failed to send ServiceX App a status '
f'message: {str(status_msg)} - Ignoring error.')

def put_file_add(self, file_info):
success = False
Expand All @@ -69,11 +73,12 @@ def put_file_add(self, file_info):
})
success = True
except requests.exceptions.ConnectionError:
print("Connection err. Retry")
__logging.exception(f'Connection error to ServiceX App. Will retry (try {attempts}'
f' out of {MAX_RETRIES}')
attempts += 1
if not success:
print("******** Failed to add new file")
print("******** Continuing")
__logging.error(f'After {attempts} tries, failed to send ServiceX App a put_file '
f'message: {str(file_info)} - Ignoring error.')

def post_preflight_check(self, file_entry):
success = False
Expand All @@ -85,11 +90,12 @@ def post_preflight_check(self, file_entry):
})
success = True
except requests.exceptions.ConnectionError:
print("Connection err. Retry")
__logging.exception(f'Connection error to ServiceX App. Will retry (try {attempts}'
f' out of {MAX_RETRIES}')
attempts += 1
if not success:
print("******** Failed to write preflight check")
print("******** Continuing")
__logging.error(f'After {attempts} tries, failed to send ServiceX App a put_file '
f'message: {str(file_entry)} - Ignoring error.')

def put_fileset_complete(self, summary):
success = False
Expand All @@ -99,8 +105,9 @@ def put_fileset_complete(self, summary):
requests.put(self.endpoint + "/complete", json=summary)
success = True
except requests.exceptions.ConnectionError:
print("Connection err. Retry")
__logging.exception(f'Connection error to ServiceX App. Will retry (try {attempts}'
f' out of {MAX_RETRIES}')
attempts += 1
if not success:
print("******** Failed to write fileset complete")
print("******** Continuing")
__logging.error(f'After {attempts} tries, failed to send ServiceX App a put_file '
f'message: {str(summary)} - Ignoring error.')

0 comments on commit a241227

Please sign in to comment.