wasp / eureka

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

TypeError: main() got an unexpected keyword argument 'loop' #9

Closed sixcorners closed 7 years ago

sixcorners commented 7 years ago

Version

wasp-eureka==1.1.1

What did you do?

I used the code from the README.

What did the code do?

Creating a client session outside of coroutine
client_session: <aiohttp.client.ClientSession object at 0x7f830398f8d0>
Traceback (most recent call last):
  File "flask-app.py", line 30, in <module>
    loop.run_until_complete(main(loop=loop))
TypeError: main() got an unexpected keyword argument 'loop'

What did you expect?

It wouldn't throw that type error.

I don't know much about python but I know how to call stuff in other C-like languages. is that loop=loop in that main method call an error?

Helpful others:

mattrasband commented 7 years ago

Can you please show the main method you're trying to call? It looks like that is in your code (rather than the library's). If you are trying to import __main__.main that isn't a supported usage - and is meant solely as a standalone way to execute the eureka registration and health heart beats.

wasp/eureka is an asyncio library and it looks like you're trying to use it in a flask app, which may not work as you are hoping.

mattrasband commented 7 years ago

Ah, sorry was on mobile originally. I fixed the README code, the loop isn't used in that example and is implicitly grabbed via asyncio.get_event_loop() in the aiohttp.ClientSession. If you'd like to provide a loop you can in the EurekaClient as a keyword argument, which is probably what I meant originally in the README docs.

Thanks for the correction!

sixcorners commented 7 years ago

"wasp/eureka is an asyncio library and it looks like you're trying to use it in a flask app, which may not work as you are hoping."

Well.. those are scary words. Should I use aiohttp or SimpleHTTPServer instead? Anyway. Ya. That fixed it thanks.