diff options
| author | Charles Cabergs <me@cacharle.xyz> | 2021-01-10 15:35:43 +0100 |
|---|---|---|
| committer | Charles Cabergs <me@cacharle.xyz> | 2021-01-10 15:35:43 +0100 |
| commit | 02f56957c2043f0da729be43fcc9a5b985ed30ca (patch) | |
| tree | 4615197e8fc537f9215d0b69976e7825dd6a3b06 /src/philo/philo.py | |
| parent | d5c0cd45ea8966416ebf0d62ae8320ce54fde501 (diff) | |
| parent | 41bdcdb45b0903b974a45094c55462951e05980f (diff) | |
| download | philosophers_test-02f56957c2043f0da729be43fcc9a5b985ed30ca.tar.gz philosophers_test-02f56957c2043f0da729be43fcc9a5b985ed30ca.tar.bz2 philosophers_test-02f56957c2043f0da729be43fcc9a5b985ed30ca.zip | |
Diffstat (limited to 'src/philo/philo.py')
| -rw-r--r-- | src/philo/philo.py | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/philo/philo.py b/src/philo/philo.py index 0e62e97..09bbc64 100644 --- a/src/philo/philo.py +++ b/src/philo/philo.py @@ -6,7 +6,7 @@ # By: cacharle <me@cacharle.xyz> +#+ +:+ +#+ # # +#+#+#+#+#+ +#+ # # Created: 2020/10/01 10:52:56 by cacharle #+# #+# # -# Updated: 2021/01/03 13:31:54 by cacharle ### ########.fr # +# Updated: 2021/01/10 15:35:14 by cacharle ### ########.fr # # # # ############################################################################ # @@ -25,7 +25,7 @@ class Philo: timeout_sleep: int, meal_num: int ): - self.logs = [] + self.logs = [] self.id = id_ self._timeout_die = timeout_die self._timeout_eat = timeout_eat @@ -56,9 +56,6 @@ class Philo: # check log event number grouped = [(e, list(g)) for e, g in itertools.groupby(self.logs, (lambda x: x.event))] for e, g in grouped[:-1]: - # if e is Event.EAT: - # if len(g) != self._meal_num: - # self._raise("Should eat {} times".format(self._meal_num)) if e is Event.FORK: if len(g) != 2: self._raise("Should take fork 2 times") @@ -127,3 +124,7 @@ class Philo: else: return 1 return 0 + + @property + def meal_num_finished(self): + return len([log for log in self.logs if log.event is Event.EAT]) >= self._meal_num |
