Skip to content

Commit 609e9f4

Browse files
committed
Update timedqueue in project 3
1 parent 6ae4469 commit 609e9f4

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

Projects/3_Adversarial Search/isolation/__init__.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,18 +69,20 @@ def start_timer(self):
6969
def put(self, item, block=True, timeout=None):
7070
if self.__stop_time and time.perf_counter() > self.__stop_time:
7171
raise StopSearch
72-
if not self.__queue.empty():
72+
try:
7373
self.__queue.get_nowait()
74+
except Empty:
75+
pass
7476
self.__queue.put_nowait((getattr(self.agent, "context", None), item))
7577

7678
def put_nowait(self, item):
77-
self.__queue.put(item, False)
79+
self.put(item, block=False)
7880

79-
def get(block=True, timeout=None):
80-
return self.__queue.get(block, timeout)
81+
def get(self, block=True, timeout=None):
82+
return self.__queue.get(block=block, timeout=timeout)
8183

8284
def get_nowait(self):
83-
return self.__queue.get_nowait()
85+
return self.get(block=False)
8486

8587
def qsize(self): return self.__queue.qsize()
8688
def empty(self): return self.__queue.empty()

Projects/3_Adversarial Search/sample_players.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def __init__(self, player_id):
3131
with open("data.pickle", "rb") as f:
3232
self.data = pickle.load(f)
3333
except (IOError, TypeError) as e:
34-
logger.warn(str(e))
34+
logger.info(str(e))
3535
self.data = None
3636

3737

0 commit comments

Comments
 (0)