Skip to content

Commit

Permalink
Add docstrings.
Browse files Browse the repository at this point in the history
  • Loading branch information
ehpor committed Aug 8, 2024
1 parent d966151 commit 2eb82da
Showing 1 changed file with 36 additions and 5 deletions.
41 changes: 36 additions & 5 deletions catkit2/testbed/tracing.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,14 @@ def write_json(f, data):


class TraceWriter:
'''
'''A writer for performance trace logs.
Parameters
----------
host : str
The host which distributes the trace messages.
port : int
The port on which the host distributes the trace messages.
'''
def __init__(self, host, port):
self.f = None
Expand All @@ -30,7 +37,17 @@ def __init__(self, host, port):
self.thread = None

def open(self, filename):
'''
'''Open the writer.
Parameters
----------
filename : str
The path to the file where to write the performance trace.
Returns
-------
TraceWriter
The current trace writer. This is for use as a context manager.
'''
self.shutdown_flag.clear()

Expand All @@ -42,7 +59,7 @@ def open(self, filename):
return self

def close(self):
'''
'''Close the writer.
'''
self.shutdown_flag.set()

Expand Down Expand Up @@ -156,12 +173,26 @@ def _loop(self):
write_json(f, data)

def __enter__(self):
'''
'''Enter the context manager.
Returns
-------
TraceWriter
The current trace writer.
'''
return self

def __exit__(self, exc_type, exc_val, exc_tb):
'''
'''Exit the context manager.
Parameters
----------
exc_type : class
The exception class.
exc_val :
The value of the exception.
exc_tb : traceback
The traceback of the exception.
'''
self.close()

Expand Down

0 comments on commit 2eb82da

Please sign in to comment.