-
Notifications
You must be signed in to change notification settings - Fork 42
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
Issue with session #36
Comments
cc @asvetlov |
PS: I might be using |
I think, it is more related with $ python main.py
Creating a client session outside of coroutine
client_session: <aiohttp.client.ClientSession object at 0x7fdb5995c4e0>
DEBUG:botocore.loaders:Loading JSON file: /home/vb/.env/lib/python3.5/site-packages/botocore/data/endpoints.json
DEBUG:botocore.loaders:Loading JSON file: /home/vb/.env/lib/python3.5/site-packages/botocore/data/s3/2006-03-01/service-2.json
DEBUG:botocore.loaders:Loading JSON file: /home/vb/.env/lib/python3.5/site-packages/botocore/data/_retry.json
DEBUG:botocore.client:Registering retry handlers for service: s3
DEBUG:botocore.hooks:Event creating-client-class.s3: calling handler <function add_generate_presigned_post at 0x7fdb5a15f048>
DEBUG:botocore.hooks:Event creating-client-class.s3: calling handler <function add_generate_presigned_url at 0x7fdb5a158400>
DEBUG:botocore.args:The s3 config key is not a dictionary type, ignoring its value of: None
DEBUG:botocore.endpoint:Setting s3 timeout as (60, 60)
DEBUG:botocore.client:Defaulting to S3 virtual host style addressing with path style addressing fallback.
DEBUG:aiotg:api_call setWebhook, {'url': 'https://vb.muminoff.uz/webhook'}
======== Running on http://127.0.0.1:8000 ========
(Press CTRL+C to quit) |
It's hard to tell to be honest, maybe if it works without uvloop then it's not aiotg problem :) Are you sure you need uvloop? I bet you'll be fine with default event loop. On the other hand, the latest changes introduced some warnings (I fixed them on 3.6 but they're still present on 3.5) so I might just as well just revert last session related changes. I really liked the old aiohttp api, and I'm getting frustrated with increasing complexity of asyncio ecosystem :( |
|
@asvetlov, however as I described above, commenting |
Weird. Following code is working. import os
from aiotg import Bot
import uvloop
import asyncio
asyncio.set_event_loop_policy(uvloop.EventLoopPolicy())
bot = Bot(api_token=os.environ["API_TOKEN"])
@bot.command(r"/echo (.+)")
def echo(chat, match):
return chat.reply(match.group(1))
bot.run_webhook(webhook_url='https://ukvzmkewrh.localtunnel.me') Versions: aiohttp==1.3.3
uvloop==0.8.0
aiotg==0.7.20 Output: $ python webhook.py
Creating a client session outside of coroutine
client_session: <aiohttp.client.ClientSession object at 0x101215358>
======== Running on http://0.0.0.0:8080 ========
(Press CTRL+C to quit) Update: added output |
Most likely the problem is inside your code not asyncio, aiohttp or uvloop :) |
@asvetlov so you mean warning message |
If it is not normal, then it is related to |
@szastupov I see some "ugly hacks" on closing session, but revert session related commits is not a right way, isn't it? Aiotg should use it. |
@shadrus sure, we have no choice :) But I'm definitely not going to force users to use async with Bot(...) as bot: ... form. It's better to have those ugly hacks as long as they don't break anything. |
@muminoff can't reproduce "Creating a client session outside of coroutine" on a standard asyncio loop. |
@szastupov I am running it on Python 3.5.2. |
@asvetlov is there any way to use aiohttp.ClientSession without forcing users to use async with? I just can't break the API... otherwise I'll just copy old wrappers and construct new session on each request |
You can use just
Be ready for breaking your hacks by new aiohttp releases. You could copy the whole aiohttp though... aiohttp has long enough deprecation period (a year and half). If you wouldn't get rid of deprecated code be ready to consequences. |
Ok, thanks. Maybe I should create ClientSession in a lazy manner 🤔 |
I've just added lazy initialisation and the warning should go away, @muminoff could you try it from master? |
@szastupov tested from master branch, seems OK now. |
Ok, cool. Just released it to pypi |
Hey @szastupov,
Was using until the new version bumped, never had an issue. After getting installed new version from pip, my code throws error. Guessing that it might have problem with
aiohttp
session.My code:
Exception:
Faced to this, this and this issues while searching with
RuntimeError: Timeout context manager should be used inside a task
.Information:
Any hints to fix or workaround?
The text was updated successfully, but these errors were encountered: