Skip to content

Commit adb446a

Browse files
authored
asyncio.iscoroutinefunction was None in destructor (#643)
1 parent 97fd0e1 commit adb446a

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

neo4j/_async/driver.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@
1616
# limitations under the License.
1717

1818

19-
import asyncio
20-
2119
from .._async_compat.util import AsyncUtil
2220
from ..addressing import Address
2321
from ..api import READ_ACCESS
@@ -197,7 +195,7 @@ async def __aexit__(self, exc_type, exc_value, traceback):
197195
await self.close()
198196

199197
def __del__(self):
200-
if not asyncio.iscoroutinefunction(self.close):
198+
if not AsyncUtil.is_async_code:
201199
self.close()
202200

203201
@property

neo4j/_async_compat/util.py

+4
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ async def callback(cb, *args, **kwargs):
4545

4646
experimental_async = experimental
4747

48+
is_async_code = True
49+
4850

4951
class Util:
5052
iter = iter
@@ -61,3 +63,5 @@ def experimental_async(message):
6163
def f_(f):
6264
return f
6365
return f_
66+
67+
is_async_code = False

neo4j/_sync/driver.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@
1616
# limitations under the License.
1717

1818

19-
import asyncio
20-
2119
from .._async_compat.util import Util
2220
from ..addressing import Address
2321
from ..api import READ_ACCESS
@@ -197,7 +195,7 @@ def __exit__(self, exc_type, exc_value, traceback):
197195
self.close()
198196

199197
def __del__(self):
200-
if not asyncio.iscoroutinefunction(self.close):
198+
if not Util.is_async_code:
201199
self.close()
202200

203201
@property

0 commit comments

Comments
 (0)