Skip to content

Commit

Permalink
Add skip_calculate flag to RouteManager.start_routemanager
Browse files Browse the repository at this point in the history
Allows us to skip calculating the initial route when starting,
so that calculation can be started separately (fixes Map-A-Droid#1289)
  • Loading branch information
MonsterMap committed Apr 26, 2023
1 parent 27e07a0 commit e25d2ce
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion mapadroid/mapping_manager/MappingManager.py
Original file line number Diff line number Diff line change
Expand Up @@ -557,7 +557,7 @@ async def routemanager_recalculate(self, routemanager_id: int) -> bool:
return False
try:
try:
await routemanager.start_routemanager()
await routemanager.start_routemanager(skip_calculate=True)
except RoutemanagerShuttingDown as e:
logger.warning("Unable to start routemanager for recalc: {}", e)
return False
Expand Down
5 changes: 3 additions & 2 deletions mapadroid/route/RouteManagerBase.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ def add_coord_to_be_removed(self, lat: float, lon: float):
return
self._coords_to_be_ignored.add(Location(lat, lon))

async def start_routemanager(self) -> bool:
async def start_routemanager(self, skip_calculate: bool = False) -> bool:
"""
Starts priority queue or whatever the implementations require
:return:
Expand All @@ -278,7 +278,8 @@ async def start_routemanager(self) -> bool:
self._is_started.set()
self._coords_to_be_ignored.clear()
logger.info("Starting routemanager {}", self.name)
await self.calculate_route(dynamic=False, overwrite_persisted_route=False)
if not skip_calculate:
await self.calculate_route(dynamic=False, overwrite_persisted_route=False)
await self._start_priority_queue()
await self._start_check_routepools()
self._init_route_queue()
Expand Down
2 changes: 1 addition & 1 deletion mapadroid/route/RouteManagerLeveling.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ async def _any_coords_left_after_finishing_route(self) -> bool:

return await self._update_routepool()

async def start_routemanager(self):
async def start_routemanager(self, skip_calculate: bool = False):
async with self._manager_mutex:
if not self._is_started.is_set():
self._is_started.set()
Expand Down
5 changes: 3 additions & 2 deletions mapadroid/route/RouteManagerQuests.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ async def _any_coords_left_after_finishing_route(self) -> bool:
return False
return True

async def start_routemanager(self):
async def start_routemanager(self, skip_calculate: bool = False):
if self._shutdown_route.is_set():
logger.info('Route is shutting down already.')
return False
Expand All @@ -114,7 +114,8 @@ async def start_routemanager(self):
logger.info("Starting routemanager")
self._is_started.set()

await self.calculate_route(dynamic=True, overwrite_persisted_route=False)
if not skip_calculate:
await self.calculate_route(dynamic=True, overwrite_persisted_route=False)
await self._start_check_routepools()

logger.info('Getting {} positions in route', len(self._route))
Expand Down

0 comments on commit e25d2ce

Please sign in to comment.