Skip to content

Commit

Permalink
Merge pull request #40 from simonsobs/pysmurf-monitor-npy-fix
Browse files Browse the repository at this point in the history
Fixed pysmurf monitor numpy bug
  • Loading branch information
jlashner authored Feb 16, 2020
2 parents 0f507c8 + fb6fea0 commit 7f79f9c
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions agents/pysmurf_monitor/pysmurf_monitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def __init__(self, agent, args):
if db_host is not None:
sql_config['host'] = db_host

self.dbpool = adbapi.ConnectionPool('mysql.connector', **sql_config)
self.dbpool = adbapi.ConnectionPool('mysql.connector', **sql_config, cp_reconnect=True)

def _add_file_callback(self, res, d):
"""Callback for when a file is successfully added to DB"""
Expand All @@ -81,7 +81,7 @@ def _add_file_callback(self, res, d):
def _add_file_errback(self, failure: Failure, d):
"""Errback for when there is an exception when adding file to DB"""
self.log.error(f"ERROR!!! {d['path']} was not added to the database")
return failure
self.log.error(f"Failure:\n{failure}")

def datagramReceived(self, _data, addr):
"""
Expand All @@ -101,6 +101,9 @@ def datagramReceived(self, _data, addr):
self.log.info("New file: {fname}", fname=data['payload']['path'])
d = data['payload'].copy()

if (d['format'] == 'npy') and (not d['path'].endswith('.npy')):
d['path'] += '.npy'

# Adds additional db info to dict
d['timestamp'] = datetime.datetime.utcfromtimestamp(d['timestamp'])
d['md5sum'] = get_md5sum(d['path'])
Expand Down

0 comments on commit 7f79f9c

Please sign in to comment.