Skip to content

Commit

Permalink
queue get blocking
Browse files Browse the repository at this point in the history
  • Loading branch information
Akshath-Singhal committed Jun 18, 2019
1 parent fec005f commit 29eeb61
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions MAVProxy/modules/mavproxy_paramedit/param_editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,8 @@ def run(self):
queue_access_start_time = time.time()
self.event_queue_lock.acquire()
request_read_after_processing_queue = False
while (self.event_queue.qsize() > 0 and
(time.time() - queue_access_start_time) < self.queue_access_timeout):
event = self.event_queue.get()
while (self.event_queue.qsize() > 0):
event = self.event_queue.get(block=True, timeout=self.queue_access_timeout)
event_type = event.get_type()

if event_type == ph_event.PEE_READ_PARAM:
Expand All @@ -52,12 +51,18 @@ def run(self):
ph_event.PEGE_READ_PARAM, param=self.param_received))
self.mp_paramedit.gui_event_queue_lock.release()

if event_type == ph_event.PEE_TIME_TO_QUIT:
elif event_type == ph_event.PEE_TIME_TO_QUIT:
self.mp_paramedit.unload()

elif event_type == ph_event.PEE_LOAD_FILE:
self.module('param').mav_param.load(
event.get_arg("path"))
self.param_received = self.module('param').mav_param
self.mp_paramedit.gui_event_queue_lock.acquire()
self.mp_paramedit.gui_event_queue.put(ParamEditorEvent(
ph_event.PEGE_READ_PARAM, param=self.param_received))
self.mp_paramedit.gui_event_queue_lock.release()


elif event_type == ph_event.PEE_SAVE_FILE:
self.module('param').mav_param.save(
Expand Down Expand Up @@ -105,7 +110,7 @@ def __init__(self, mpstate):
self.mpstate.param_editor = self

self.last_unload_check_time = time.time()
self.unload_check_interval = 0.02 # seconds
self.unload_check_interval = 0.1 # seconds

self.time_to_quit = False
self.mavlink_message_queue = multiproc.Queue()
Expand Down

0 comments on commit 29eeb61

Please sign in to comment.