Skip to content

Commit

Permalink
Return None when the bulletin length is too long
Browse files Browse the repository at this point in the history
  • Loading branch information
andreleblanc11 authored and petersilva committed Nov 8, 2024
1 parent 4898769 commit b91e14b
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion sarracenia/flowcb/send/am.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@ def wrapbulletin(self, sarra_msg):

# Step out of the function if the bulletin size is too big
if len(strdata) > self.o.fileSizeMax:
raise Exception(f"Bulletin length too long. Bulletin limit length: {self.o.MaxBulLen}. Latest bulletin length: {len(strdata)}. Path to bulletin: {msg_path}")
logger.error(f"Bulletin length too long. Bulletin limit length: {self.o.fileSizeMax}. Latest bulletin length: {len(strdata)}. Path to bulletin: {msg_path}")
return None

## Attach rest of header with NULLs (if not long enough)
nulheader = ['\0' for _ in range(size)]
Expand Down Expand Up @@ -150,6 +151,10 @@ def send(self, bulletin):
try:
self.packed_bulletin = self.wrapbulletin(bulletin)

# We don't want to send nothing.
if self.packed_bulletin == None:
return False

while True:
try:
bytesSent = self.s.send(self.packed_bulletin)
Expand Down

0 comments on commit b91e14b

Please sign in to comment.