Skip to content

Commit

Permalink
More WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
JDBetteridge committed Nov 15, 2023
1 parent f8fed18 commit a4372e6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
PETSC_ARCH: default
PETSC_CONFIGURE_OPTIONS: --with-debugging=1 --with-shared-libraries=1 --with-c2html=0 --with-fortran-bindings=0
RDMAV_FORK_SAFE: 1
PYOP2_LOG_LEVEL: DEBUG
PYOP2_CI_TESTS: 1
timeout-minutes: 60

steps:
Expand Down
18 changes: 13 additions & 5 deletions pyop2/mpi.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@
_DUPED_COMM_DICT = {}
# Flag to indicate whether we are in cleanup (at exit)
PYOP2_FINALIZED = False

# Flag for outputting information at the end of testing (do not abuse!)
_running_under_pytest = bool(os.environ.get('PYOP2_CI_TESTS'))

class PyOP2CommError(ValueError):
pass
Expand Down Expand Up @@ -178,6 +179,7 @@ def delcomm_outer(comm, keyval, icomm):
# This will raise errors at cleanup time as some objects are already
# deleted, so we just skip
# ~ if not PYOP2_FINALIZED:
debug = finalize_safe_debug()
if keyval not in (innercomm_keyval, compilationcomm_keyval):
raise PyOP2CommError("Unexpected keyval")

Expand Down Expand Up @@ -484,15 +486,21 @@ def compilation_comm(comm):
return comp_comm


def finalize_safe_debug():
if PYOP2_FINALIZED:
if logger.level > DEBUG and not _running_under_pytest:
debug = lambda string: None
else:
debug = lambda string: print(string)
return debug


@atexit.register
def _free_comms():
"""Free all outstanding communicators."""
global PYOP2_FINALIZED
PYOP2_FINALIZED = True
if logger.level > DEBUG:
debug = lambda string: None
else:
debug = lambda string: print(string)
debug = finalize_safe_debug()
debug("PyOP2 Finalizing")
# Collect garbage as it may hold on to communicator references

Expand Down

0 comments on commit a4372e6

Please sign in to comment.