Skip to content
This repository has been archived by the owner on Jun 26, 2021. It is now read-only.

Commit

Permalink
Merge pull request #236 from delira-dev/fixed_logging
Browse files Browse the repository at this point in the history
Fixed logging
  • Loading branch information
ORippler authored Dec 3, 2019
2 parents bd6f4ca + 28d5fe5 commit 64ce57b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
2 changes: 1 addition & 1 deletion delira/logging/base_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ def _log_item(self):
"""
# get item from dict
process_item = self._queue.get(timeout=0.5)
process_item = self._queue.get(timeout=0.001)
# log item if item is dict
if isinstance(process_item, dict):

Expand Down
10 changes: 6 additions & 4 deletions delira/logging/base_logger.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from multiprocessing import Queue, Event
from queue import Full
from multiprocessing.queues import Queue as MpQueue
from threading import Event
from queue import Queue, Full
from delira.logging.base_backend import BaseBackend
from delira.utils.dict_reductions import get_reduction, possible_reductions, \
reduce_dict
Expand Down Expand Up @@ -231,8 +232,9 @@ def close(self):
"""
if hasattr(self, "_flush_queue"):
self._flush_queue.close()
self._flush_queue.join_thread()
if isinstance(self._flush_queue, MpQueue):
self._flush_queue.close()
self._flush_queue.join_thread()

if hasattr(self, "abort_event"):
self._abort_event.set()
Expand Down
6 changes: 5 additions & 1 deletion delira/utils/dict_reductions.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,11 @@ def reduce_dict(items: list, reduce_fn) -> dict:

for k, v in result_dict.items():
# check if all items are equal
if all([_v == v[0] for _v in v[1:]]):
equals = [_v == v[0] for _v in v[1:]]
for idx, equality in enumerate(equals):
if isinstance(equality, np.ndarray):
equals[idx] = equality.all()
if all(equals):
# use first item since they are equal
result_dict[k] = v[0]
else:
Expand Down

0 comments on commit 64ce57b

Please sign in to comment.