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

Creating a client session outside of coroutine #13

Open
ghost opened this issue Dec 5, 2018 · 1 comment
Open

Creating a client session outside of coroutine #13

ghost opened this issue Dec 5, 2018 · 1 comment

Comments

@ghost
Copy link

ghost commented Dec 5, 2018

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
Copy link

ylgu commented Jan 2, 2019

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant