-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Gameserver update: add processing of disappeared processes & update s…
…tatistics (#78) * Add handling in case the process disappears * Update statistics collector: use it only for one epoch * Add synchronization to the `fail` method * Restructure & add processing of process killing by system * Add `FailedMaps` instead of `Status` & refactor * Add info about failed maps to stats table * Fix logging of exception * `GameError`: Replace error with error_name & add error's description to `GameInterruptedError` * Fix types * Remove statscollector from GameError * Save 'FunctionTimedOut'ed maps * Remove extra exception handler. * Move `avg_by_attr` from StatisticsCollector * Fix calculation of average coverage --------- Co-authored-by: Anya497 <chi.vinny0702@gmail.com>
- Loading branch information
1 parent
03003dc
commit fac6464
Showing
11 changed files
with
253 additions
and
141 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
from typing import TypeVar | ||
|
||
T = TypeVar("T") | ||
|
||
|
||
def inheritors(cls: T) -> set[T]: | ||
subclasses: set[T] = set() | ||
work = [cls] | ||
while work: | ||
parent = work.pop() | ||
for child in parent.__subclasses__(): | ||
if child not in subclasses: | ||
subclasses.add(child) | ||
work.append(child) | ||
return subclasses |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
from abc import ABC, abstractmethod | ||
|
||
|
||
class GameInterruptedError(Exception, ABC): | ||
"""Game was unexpectedly interrupted due to external reasons""" | ||
|
||
@property | ||
@abstractmethod | ||
def desc(self): | ||
pass | ||
|
||
|
||
class ProcessStoppedError(GameInterruptedError): | ||
"""SVM's process unexpectedly stopped""" | ||
|
||
desc = "SVM's process unexpectedly stopped" | ||
|
||
|
||
class ConnectionLostError(GameInterruptedError): | ||
"""Connection to SVM was lost""" | ||
|
||
desc = "Connection to SVM was lost" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
from func_timeout import FunctionTimedOut | ||
from connection.errors_connection import GameInterruptedError | ||
from common.utils import inheritors | ||
from common.game import GameMap2SVM | ||
|
||
|
||
class GameError(Exception): | ||
|
||
def __init__( | ||
self, | ||
game_map2svm: GameMap2SVM, | ||
error_name: str, | ||
) -> None: | ||
self._map = game_map2svm | ||
self._error_name = error_name | ||
|
||
super().__init__(game_map2svm, error_name) | ||
|
||
def need_to_save_map(self): | ||
gie_inheritors = inheritors(GameInterruptedError) | ||
need_to_save_classes = list(gie_inheritors) + [FunctionTimedOut] | ||
return self._error_name in map(lambda it: it.__name__, need_to_save_classes) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.