forked from p15670423/monkey
Agent: Rename some variables in `send_all_events_to_island`
This commit is contained in:
parent
6520fe2c90
commit
8f4aefda74
|
@ -23,7 +23,7 @@ class send_all_events_to_island:
|
||||||
self._server_address = server_address
|
self._server_address = server_address
|
||||||
self._queue: queue.Queue[AbstractAgentEvent] = queue.Queue()
|
self._queue: queue.Queue[AbstractAgentEvent] = queue.Queue()
|
||||||
|
|
||||||
self._send_to_island_thread = self.batch_events_thread(
|
self._send_to_island_thread = self._batch_and_send_events_thread(
|
||||||
self._queue, self._server_address, DEFAULT_TIME_PERIOD
|
self._queue, self._server_address, DEFAULT_TIME_PERIOD
|
||||||
)
|
)
|
||||||
self._send_to_island_thread.start()
|
self._send_to_island_thread.start()
|
||||||
|
@ -37,21 +37,21 @@ class send_all_events_to_island:
|
||||||
def _serialize_event(self, event: AbstractAgentEvent, topic_name: str):
|
def _serialize_event(self, event: AbstractAgentEvent, topic_name: str):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
class batch_events_thread:
|
class _batch_and_send_events_thread:
|
||||||
def __init__(self, queue_of_events: queue.Queue, server_address: str, time_period: int):
|
def __init__(self, queue_of_events: queue.Queue, server_address: str, time_period: int):
|
||||||
self._queue = queue_of_events
|
self._queue = queue_of_events
|
||||||
self._server_address = server_address
|
self._server_address = server_address
|
||||||
self._time_period = time_period
|
self._time_period = time_period
|
||||||
|
|
||||||
self._event_batch = set()
|
self._event_batch = set()
|
||||||
self._should_run_batch_thread = True
|
self._should_run_batch_and_send_thread = True
|
||||||
|
|
||||||
def start(self):
|
def start(self):
|
||||||
self._should_run_batch_thread = True
|
self._should_run_batch_and_send_thread = True
|
||||||
self._batch_events_thread = threading.Thread(
|
self._batch_and_send_thread = threading.Thread(
|
||||||
name="SendEventsToIslandInBatchesThread", target=self._manage_event_batches
|
name="SendEventsToIslandInBatchesThread", target=self._manage_event_batches
|
||||||
)
|
)
|
||||||
self._batch_events_thread.start()
|
self._batch_and_send_thread.start()
|
||||||
|
|
||||||
def _manage_event_batches(self):
|
def _manage_event_batches(self):
|
||||||
timer = Timer()
|
timer = Timer()
|
||||||
|
@ -59,7 +59,7 @@ class send_all_events_to_island:
|
||||||
|
|
||||||
self._event_batch = {}
|
self._event_batch = {}
|
||||||
|
|
||||||
while self._should_run_batch_thread:
|
while self._should_run_batch_and_send_thread:
|
||||||
self._add_next_event_to_batch()
|
self._add_next_event_to_batch()
|
||||||
|
|
||||||
if timer.is_expired():
|
if timer.is_expired():
|
||||||
|
@ -99,5 +99,5 @@ class send_all_events_to_island:
|
||||||
self._send_events_to_island()
|
self._send_events_to_island()
|
||||||
|
|
||||||
def stop(self):
|
def stop(self):
|
||||||
self._should_run_batch_thread = False
|
self._should_run_batch_and_send_thread = False
|
||||||
self._batch_events_thread.join()
|
self._batch_and_send_thread.join()
|
||||||
|
|
Loading…
Reference in New Issue