Skip to content

Commit

Permalink
Usage Tracking: Only log messages when tracking is enabled (#3748)
Browse files Browse the repository at this point in the history
Fix the bug where the DFK logs that it is entering usage tracking code
in a way that suggests it is logging usage tracking data, even when
turned off.

# Changed Behaviour

The DFK will only log messages about usage tracking data being sent when
usage tracking is enabled.

# Fixes

Fixes #3740 

## Type of change

- Bug fix

---------

Co-authored-by: Ben Clifford <[email protected]>
  • Loading branch information
NishchayKarle and benclifford authored Jan 20, 2025
1 parent 6ac930e commit 4e3e6b5
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
2 changes: 0 additions & 2 deletions parsl/dataflow/dflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -1200,10 +1200,8 @@ def cleanup(self) -> None:
self._checkpoint_timer.close()

# Send final stats
logger.info("Sending end message for usage tracking")
self.usage_tracker.send_end_message()
self.usage_tracker.close()
logger.info("Closed usage tracking")

logger.info("Closing job status poller")
self.job_status_poller.close()
Expand Down
21 changes: 13 additions & 8 deletions parsl/usage_tracking/usage.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,12 +213,14 @@ def send_UDP_message(self, message: bytes) -> None:

def send_start_message(self) -> None:
if self.tracking_level:
logger.info("Sending start message for usage tracking")
self.start_time = time.time()
message = self.construct_start_message()
self.send_UDP_message(message)

def send_end_message(self) -> None:
if self.tracking_level == 3:
logger.info("Sending end message for usage tracking")
message = self.construct_end_message()
self.send_UDP_message(message)

Expand All @@ -229,11 +231,14 @@ def close(self, timeout: float = 10.0) -> None:
definitely either: going to behave broadly the same as to SIGKILL,
or won't respond to SIGTERM.
"""
for proc in self.procs:
logger.debug("Joining usage tracking process %s", proc)
proc.join(timeout=timeout)
if proc.is_alive():
logger.warning("Usage tracking process did not end itself; sending SIGKILL")
proc.kill()

proc.close()
if self.tracking_level:
logger.info("Closing usage tracking")

for proc in self.procs:
logger.debug("Joining usage tracking process %s", proc)
proc.join(timeout=timeout)
if proc.is_alive():
logger.warning("Usage tracking process did not end itself; sending SIGKILL")
proc.kill()

proc.close()

0 comments on commit 4e3e6b5

Please sign in to comment.