[issue39483] Proposial add loop parametr to run in asyncio

2020-02-11 Thread Yury Selivanov
Yury Selivanov added the comment: Андрей, Here's how you can fix your example: import asyncio class Singleton: _LOCK = None _LOOP = None @classmethod async def create(cls): if cls._LOOP is None: cls._LOOP = asyncio.get_running_loop()

[issue39483] Proposial add loop parametr to run in asyncio

2020-02-02 Thread Andrew Svetlov
Change by Andrew Svetlov : -- resolution: -> wont fix status: open -> closed ___ Python tracker ___ ___ Python-bugs-list mailing

[issue39483] Proposial add loop parametr to run in asyncio

2020-02-01 Thread Caleb Hattingh
Caleb Hattingh added the comment: Hmm, my recent comment looks rude but I didn't intend it to be that way. What I mean is: there are many, many more users of asyncio.run than there are of teleton, so any change made to asyncio.run is going to affect more people than the other way round. So

[issue39483] Proposial add loop parametr to run in asyncio

2020-02-01 Thread Caleb Hattingh
Caleb Hattingh added the comment: @heckad You should instead ask the maintainers of teleton how to use their library with asyncio.run, not the other way round. -- nosy: +cjrh ___ Python tracker

[issue39483] Proposial add loop parametr to run in asyncio

2020-01-31 Thread Андрей Казанцев
Андрей Казанцев added the comment: Where can I find issue which you are discussing for this thread? -- resolution: rejected -> status: closed -> open ___ Python tracker ___

[issue39483] Proposial add loop parametr to run in asyncio

2020-01-31 Thread Andrew Svetlov
Andrew Svetlov added the comment: Explicit error is better than error-prone design. Think that we will deprecate asyncio.get_event_loop() and the loop instantiation on-demand in the main thread. -- resolution: -> rejected stage: patch review -> resolved status: open -> closed

[issue39483] Proposial add loop parametr to run in asyncio

2020-01-30 Thread Андрей Казанцев
Андрей Казанцев added the comment: @asvetlov, I provided an example where else this useful feature would be. What do you think? -- ___ Python tracker ___

[issue39483] Proposial add loop parametr to run in asyncio

2020-01-29 Thread Андрей Казанцев
Андрей Казанцев added the comment: How to make singleton class? I wrote this ``` import asyncio class Singleton: _CREATE_LOCK = asyncio.Lock() @classmethod async def create(cls): if not hasattr(cls, '_Singleton__instance'): async with cls._CREATE_LOCK:

[issue39483] Proposial add loop parametr to run in asyncio

2020-01-29 Thread Andrew Svetlov
Andrew Svetlov added the comment: A client that creates a loop implicitly in the constructor is a weird design from my perspective. You are free to use it, sure -- but please let us keep the freedom to not support such corner cases by asyncio.run() Sorry, I don't know the telethon library

[issue39483] Proposial add loop parametr to run in asyncio

2020-01-29 Thread Андрей Казанцев
Андрей Казанцев added the comment: I create the client object in `bot` file. If I import it then it creates loop when will import and then when I run it I will get errors attaching to a different loop. Another way to use `import` statement in main. This is blocking code. What to choose?

[issue39483] Proposial add loop parametr to run in asyncio

2020-01-29 Thread Andrew Svetlov
Andrew Svetlov added the comment: -1. I rather suggest updating telethon example in the following matter: async with main(): with TelegramClient('anon', api_id, api_hash) as client: await client.send_message('me', 'Hello, myself!') You PR brings more problems than fixes: the loop

[issue39483] Proposial add loop parametr to run in asyncio

2020-01-29 Thread Андрей Казанцев
Change by Андрей Казанцев : -- keywords: +patch pull_requests: +17627 stage: -> patch review pull_request: https://github.com/python/cpython/pull/18248 ___ Python tracker ___

[issue39483] Proposial add loop parametr to run in asyncio

2020-01-29 Thread Андрей Казанцев
New submission from Андрей Казанцев : Sometimes need get loop from another place and run corutine in it. For example when use teleton lib. Example from this lib https://docs.telethon.dev/en/latest/basic/signing-in.html#id2 suggests using ```client.loop.run_until_complete``` but it's not