@@ -305,19 +305,18 @@ def source_entity_handler(transfer_params: TransferParams, source_handler: Sourc
305305 trans_mode = transfer_params .transmission_mode ,
306306 closure_requested = not transfer_params .no_closure ,
307307 )
308- packet_received = False
309308 print (f"SRC HANDLER: Inserting Put Request: { put_request } " )
310309 with open (SOURCE_FILE ) as file :
311310 file_content = file .read ()
312311 print (f"File content of source file { SOURCE_FILE } : { file_content } " )
313312 assert source_handler .put_request (put_request )
314- packet = None
313+
315314 while True :
315+ packet = None
316316 try :
317317 # We are getting the packets from a Queue here, they could for example also be polled
318318 # from a network.
319319 packet = DEST_TO_SOURCE_QUEUE .get (False )
320- packet_received = True
321320 except Empty :
322321 pass
323322 fsm_result = source_handler .state_machine (packet )
@@ -332,7 +331,7 @@ def source_entity_handler(transfer_params: TransferParams, source_handler: Sourc
332331 SOURCE_TO_DEST_QUEUE .put (next_pdu_wrapper .pdu )
333332 packet_sent = True
334333 # If there is no work to do, put the thread to sleep.
335- if not packet_received and not packet_sent :
334+ if packet is None and not packet_sent :
336335 time .sleep (0.5 )
337336 # Transaction done
338337 if fsm_result .states .state == CfdpState .IDLE :
@@ -342,12 +341,10 @@ def source_entity_handler(transfer_params: TransferParams, source_handler: Sourc
342341
343342def dest_entity_handler (transfer_params : TransferParams , dest_handler : DestHandler ) -> None :
344343 first_packet = True
345- packet_received = False
346- packet = None
347344 while True :
345+ packet = None
348346 try :
349347 packet = SOURCE_TO_DEST_QUEUE .get (False )
350- packet_received = True
351348 if first_packet :
352349 first_packet = False
353350 except Empty :
@@ -363,7 +360,7 @@ def dest_entity_handler(transfer_params: TransferParams, dest_handler: DestHandl
363360 DEST_TO_SOURCE_QUEUE .put (next_pdu_wrapper .pdu )
364361 packet_sent = True
365362 # If there is no work to do, put the thread to sleep.
366- if not packet_received and not packet_sent :
363+ if packet is None and not packet_sent :
367364 time .sleep (0.5 )
368365 # Transaction done
369366 if not first_packet and fsm_result .states .state == CfdpState .IDLE :
0 commit comments