Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

asyncio.iscoroutinefunction was None in destructor #643

Merged
merged 1 commit into from
Jan 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions neo4j/_async/driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@
# limitations under the License.


import asyncio

from .._async_compat.util import AsyncUtil
from ..addressing import Address
from ..api import READ_ACCESS
Expand Down Expand Up @@ -197,7 +195,7 @@ async def __aexit__(self, exc_type, exc_value, traceback):
await self.close()

def __del__(self):
if not asyncio.iscoroutinefunction(self.close):
if not AsyncUtil.is_async_code:
self.close()

@property
Expand Down
4 changes: 4 additions & 0 deletions neo4j/_async_compat/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ async def callback(cb, *args, **kwargs):

experimental_async = experimental

is_async_code = True


class Util:
iter = iter
Expand All @@ -61,3 +63,5 @@ def experimental_async(message):
def f_(f):
return f
return f_

is_async_code = False
4 changes: 1 addition & 3 deletions neo4j/_sync/driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@
# limitations under the License.


import asyncio

from .._async_compat.util import Util
from ..addressing import Address
from ..api import READ_ACCESS
Expand Down Expand Up @@ -197,7 +195,7 @@ def __exit__(self, exc_type, exc_value, traceback):
self.close()

def __del__(self):
if not asyncio.iscoroutinefunction(self.close):
if not Util.is_async_code:
self.close()

@property
Expand Down