wasp / eureka

Async Eureka Client (Netflix OSS, Spring Cloud Service Discovery)
Apache License 2.0
19 stars 8 forks source link

Creating a client session outside of coroutine #13

Open ghost opened 5 years ago

ghost commented 5 years ago

Version

Paste the version from pip freeze | grep "eureka" wasp-eureka==1.1.1

What did you do?

Using wasp_eureka register a python client to spring cloud.

Please provide a code example. If anything is private or sensitive, include a placeholder value [import asyncio

from wasp_eureka import EurekaClient

app_name = 'test-app'

port = 8080

ip = '127.0.0.1' my_eureka_url = 'my_url' loop = asyncio.get_event_loop()

eureka = EurekaClient(app_name, port, ip, eureka_url=my_eureka_url, loop=loop) async def main(): result = await eureka.register() assert result, 'Unable to register' while True: await asyncio.sleep(30) await eureka.renew() loop.run_until_complete(main())](url)

What did the code do?

/usr/local/lib/python3.7/site-packages/wasp_eureka/client.py:28: UserWarning: Creating a client session outside of coroutine is a very dangerous idea 'Content-Type': 'application/json', Creating a client session outside of coroutine client_session: <aiohttp.client.ClientSession object at 0x116a6f3c8> Traceback (most recent call last): File "/Users/aaron/mioto/pixel/PixelNlp/test1.py", line 32, in loop.run_until_complete(main()) File "/usr/local/Cellar/python/3.7.0/Frameworks/Python.framework/Versions/3.7/lib/python3.7/asyncio/base_events.py", line 568, in run_until_complete return future.result() File "/Users/aaron/mioto/pixel/PixelNlp/test1.py", line 21, in main result = await eureka.register() File "/usr/local/lib/python3.7/site-packages/wasp_eureka/client.py", line 158, in register return await self._do_req(url, method='POST', data=json.dumps(payload)) File "/usr/local/lib/python3.7/site-packages/wasp_eureka/client.py", line 249, in _do_req await resp.text()) wasp_eureka.exc.EurekaException sys:1: RuntimeWarning: coroutine 'ClientSession.close' was never awaited Unclosed client session client_session: <aiohttp.client.ClientSession object at 0x116a6f3c8> Unclosed connector connections: ['[(<aiohttp.client_proto.ResponseHandler object at 0x117258648>, 0.459410832)]'] connector: <aiohttp.connector.TCPConnector object at 0x116ae15c0>

What did you expect?

Please outline the expected behavior

ylgu commented 5 years ago

I got it too. Do you find the way to resolve it?