Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid loading the entire log files into memory #105

Merged
merged 5 commits into from
Nov 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/fprime_gds/common/files/downlinker.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@ def handle_data(self, data):
"""
# Initialize all relevant DATA packet attributes into variables from file_data
offset = data.offset
data_bytes = data.dataVar
if self.state != FileStates.RUNNING:
LOGGER.warning("Received unexpected data packet for offset: %d", offset)
else:
Expand All @@ -124,6 +123,7 @@ def handle_data(self, data):
self.sequence,
data.seqID,
)
data_bytes = data.dataVar
# Write the data information to the file
self.active.write(data_bytes, offset)
self.active.seek = offset + len(data_bytes)
Expand Down
2 changes: 1 addition & 1 deletion src/fprime_gds/common/loaders/dict_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,4 +112,4 @@ def construct_dicts(self, path):
for both should be data_template classes. This base class only
returns empty dictionaries.
"""
return dict(), dict(), ("unknown", "unknown")
return {}, {}, ("unknown", "unknown")
2 changes: 1 addition & 1 deletion src/fprime_gds/executables/run_deployment.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def launch_process(cmd, logfile=None, name=None, env=None, launch_time=5):
try:
if logfile is not None:
with open(logfile) as file_handle:
for line in file_handle.readlines():
for line in file_handle:
print(f" [LOG] {line.strip()}", file=sys.stderr)
except Exception:
pass
Expand Down
14 changes: 3 additions & 11 deletions src/fprime_gds/executables/tcpserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,9 +221,7 @@ def recv(self, l):
except OSError as err:
if err.errno == errno.ECONNRESET:
print(
"Socket error "
+ str(err.errno)
+ " (Connection reset by peer) occurred on recv()."
f"Socket error {str(err.errno)} (Connection reset by peer) occurred on recv()."
)
else:
print(f"Socket error {str(err.errno)} occurred on recv().")
Expand All @@ -237,11 +235,7 @@ def readHeader(self):
header = self.recv(5)

if len(header) == 0:
print(
"Header information is empty, client "
+ self.name.decode(DATA_ENCODING)
+ " exiting."
)
print(f"Header information is empty, client {self.name.decode(DATA_ENCODING)} exiting.")
return header
if header == b"List\n":
return b"List"
Expand All @@ -260,9 +254,7 @@ def readData(self, header):
FSW receives commands of various lengths.
"""
data = b""
if header == b"List":
return b""
elif header == b"Quit":
if header in [b"List", b"Quit"]:
return b""
dst = header.split(b" ")[1].strip(b" ")
if dst == b"FSW":
Expand Down