Skip to content

Commit

Permalink
Fixes for aioca 1.8.*
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexanderWells-diamond committed Nov 4, 2024
1 parent 35bb833 commit 7f56567
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import string
import subprocess
import sys
from packaging.version import Version
from typing import Any
import pytest

Expand Down Expand Up @@ -73,12 +74,18 @@ def cothread_ioc():


def aioca_cleanup():
from aioca import purge_channel_caches, _catools
from aioca import purge_channel_caches, _catools, __version__
# Unregister the aioca atexit handler as it conflicts with the one installed
# by cothread. If we don't do this we get a seg fault. This is not a problem
# in production as we won't mix aioca and cothread, but we do mix them in
# the tests so need to do this.
atexit.unregister(_catools._Context._destroy_context)
# In aioca 1.8 the name of the cleanup function changed.
if Version(__version__) >= Version("1.8"):
unregister_func = _catools._Context._teardown
else:
unregister_func = _catools._Context._destroy_context

atexit.unregister(unregister_func)
# purge the channels before the event loop goes
purge_channel_caches()

Expand Down

0 comments on commit 7f56567

Please sign in to comment.