I have been using https://github.com/Azure-Samples/azure-cosmos-db-graph-python-getting-started project to work with cosmosdb-gremlin.
project work fine when i am running it as python function on windows.
now i am trying to convert this code into azure-function.
I am able to convert and run, faced couple of issues (tornado+python3.8 compatibility issue) (nest_asyncio). now i have resolved those errors but i am still getting following (attached screenshot)
this error comes, when i am trying to close the connection.
client.close().
so to avoid complete flow failure, i just wrapped it inside the try/catch. so now flow is going ahead and functionally i do not see any side effect.
but then i noticed something, the thread count keeps increasing with each run. I am not sure if this is because i am not closing error. I am afraid I may be accumulating orphan threads.
please suggest what can be done?
I am trying to modify code inside gremlin-python package, because then it may work locally, but i will have other issues while deploying it on azure.
i am using python 3.8.5
i was able to solve it by implementing 2 steps.
changed axuze function by adding async.
async def main(req: func.HttpRequest) -> func.HttpResponse:
added these 2 lines top of the file...
import nest_asyncio
nest_asyncio.apply()
downgraded tornado by adding following entry in requirement.txt
tornado==4.5.3