Skip to content

Commit cdcaabc

Browse files
Fixes for aioca 1.8.*
1 parent 35bb833 commit cdcaabc

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

tests/conftest.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import string
77
import subprocess
88
import sys
9+
from packaging.version import Version
910
from typing import Any
1011
import pytest
1112

@@ -73,12 +74,19 @@ def cothread_ioc():
7374

7475

7576
def aioca_cleanup():
76-
from aioca import purge_channel_caches, _catools
77+
from aioca import purge_channel_caches, _catools, __version__
7778
# Unregister the aioca atexit handler as it conflicts with the one installed
7879
# by cothread. If we don't do this we get a seg fault. This is not a problem
7980
# in production as we won't mix aioca and cothread, but we do mix them in
8081
# the tests so need to do this.
81-
atexit.unregister(_catools._Context._destroy_context)
82+
# In aioca 1.8 the name of the function changed, but it also dropped support
83+
# for Python 3.7. Once we drop that Python version we can remove this check.
84+
if Version(__version__) >= Version("1.8"):
85+
unregister_func = _catools._Context._teardown
86+
else:
87+
unregister_func = _catools._Context._destroy_context
88+
89+
atexit.unregister(unregister_func)
8290
# purge the channels before the event loop goes
8391
purge_channel_caches()
8492

0 commit comments

Comments
 (0)