Skip to content

Commit

Permalink
create backup task: fixed waiting for world_save_done hangs if server…
Browse files Browse the repository at this point in the history
… stops
  • Loading branch information
Fallen-Breath committed Mar 10, 2024
1 parent de76e94 commit 467bac1
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 1 deletion.
5 changes: 5 additions & 0 deletions prime_backup/mcdr/mcdr_entrypoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,11 @@ def on_server_start(server: PluginServerInterface):
online_player_counter.on_server_start()


def on_server_stop(server: PluginServerInterface, server_return_code: int):
if init_ok:
task_manager.on_server_stopped()


def on_player_joined(server: PluginServerInterface, player: str, info: Info):
if init_ok and online_player_counter is not None:
online_player_counter.on_player_joined(player)
Expand Down
1 change: 1 addition & 0 deletions prime_backup/mcdr/task/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
class TaskEvent(enum.Enum):
plugin_unload = enum.auto()
world_save_done = enum.auto()
server_stopped = enum.auto()
operation_confirmed = enum.auto()
operation_aborted = enum.auto()

Expand Down
2 changes: 1 addition & 1 deletion prime_backup/mcdr/task/backup/create_backup_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,5 +74,5 @@ def on_event(self, event: TaskEvent):
super().on_event(event)
if event == TaskEvent.plugin_unload:
self.world_saved_done.set()
elif event == TaskEvent.world_save_done:
elif event in [TaskEvent.world_save_done, TaskEvent.server_stopped]:
self.world_saved_done.set()
3 changes: 3 additions & 0 deletions prime_backup/mcdr/task_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,3 +219,6 @@ def pre_send(holder: TaskHolder):
def on_world_saved(self):
self.worker_heavy.send_event_to_current_task(TaskEvent.world_save_done)

def on_server_stopped(self):
self.worker_heavy.send_event_to_current_task(TaskEvent.server_stopped)

0 comments on commit 467bac1

Please sign in to comment.