python-asyncio Questions
4
Solved
import asyncio
from threading import Thread
from datetime import datetime
from aiogram import Bot, Dispatcher, executor, types
API_TOKEN = ''
bot = Bot(token=API_TOKEN)
dp = Dispatcher(bot)
chat...
Photoplay asked 27/12, 2019 at 14:46
2
Solved
I am looking for the best solution for communication between async tasks and methods/functions that run in a thread pool executor from concurrent.futures. In previous synchronous projects, I would ...
Headstall asked 8/1, 2020 at 16:38
2
Solved
I want to use threading.Lock() in a async function, asyncio.Lock() is not thread safe so I cannot do with await asyncio.Lock():. The reason I need to use threading.Lock() is because this object may...
Footboy asked 14/8, 2020 at 21:49
3
I build a chatapplication using Aiohttp server and using python-socket-io. When i tried to host this application in nginx i found this error in supervisor error from error log of supervisor(error l...
Correctitude asked 27/5, 2022 at 5:19
3
Solved
Word of notice: This is my first approach with asyncio, so I might have done something really stupid.
Scenario is as follows:
I need to "http-ping" a humongous list of urls to check if th...
Snowman asked 26/10, 2020 at 9:54
0
Overview
I have a server which has an an open WebSocket connection with one client application. This client application (android app) can send live microphone audio data. What the server has to do ...
Nightdress asked 31/8 at 15:27
1
Note: despite I'm beginning my question with a microdot example, this is just because I've first observed the later described behavior with an attempt to re-start a microdot server after aborting a...
Sestertium asked 19/8 at 6:7
2
Solved
This is similar to Calling coroutines in asyncio.Protocol.data_received but I think it warrants a new question.
I have a simple server set up like this
loop.create_unix_server(lambda: protocol, p...
Immiscible asked 18/3, 2015 at 15:39
2
Solved
I wish to use shelve in an asyncio program and I fear that every change will cause the main event loop to stall.
While I don't mind the occasional slowdown of the pickling operation, the disk write...
Dejecta asked 8/8 at 21:27
2
Solved
The docs for cancel make it sound like you should usually propagate CancelledError exceptions:
Therefore, unlike Future.cancel(), Task.cancel() does not guarantee that the Task will be cancelled, ...
Crucible asked 10/2 at 19:54
6
Solved
I have this code:
import os
import time
import asyncio
async def run_command(*args):
"""
Example from:
http://asyncio.readthedocs.io/en/latest/subprocess.html
"""...
Grappling asked 19/6, 2017 at 14:38
4
function i am trying to call from my flask-socketio server
from flask_socketio import emit
import asyncio
async def myfunc():
for i in range(10):
j = 1*3
await emit('update', {'j':j})
in my...
Halona asked 3/7, 2019 at 14:27
4
Solved
I am trying to use async to get the HTML from a list of urls (identified by ids). I need to use a proxy.
I am trying to use aiohttp with proxies like below:
import asyncio
import aiohttp
from bs4...
Burdick asked 17/8, 2018 at 2:54
1
I use asyncio and aiohttp in my code, and it runs perfectly fine on my work laptop. However, when I run it on my virtual machine from my work laptop, I run into this error "The semaphore timeo...
Lop asked 6/3 at 16:1
3
I'm trying to determine how to correctly use cProfile and pstats with asyncio code. I am profiling my script by running cProfile.run('loop.run_until_complete(main())', 'profile.stats').
After usi...
Nealson asked 15/2, 2019 at 23:15
2
Solved
I am updating one of my Python packages so it is asynchronous (using aiohttp instead of requests). I am also updating my unit tests so they work with the new asynchronous version, but I'm having so...
Leventhal asked 20/1, 2019 at 17:15
4
Solved
I get the exception "Cannot write to closing transport" raised from aiohttp.http_writer.StreamWriter#_write, but only in a fraction of cases.
The relevant snippet.
session: aiohttp.ClientSession...
Daughter asked 31/1, 2019 at 14:2
2
Solved
I want to connect to a list of a lot of different sites very fast.
Im using asyncio to do this in an asynchronous manner and now want to
add a timeout for when connections should be ignored if the...
Decoder asked 20/4, 2015 at 19:17
10
Solved
I have a test to verify an exception is thrown from an async response, which I'm using pytest-asyncio version 0.10.0 to run.
Code is basically:
class TestThis:
@pytest.mark.asyncio
def test_the...
Certes asked 4/4, 2020 at 1:27
9
Solved
I want to use asyncio in combination with a tkinter GUI.
I am new to asyncio and my understanding of it is not very detailed.
The example here starts 10 task when clicking on the first button. The ...
Gwyn asked 19/12, 2017 at 21:57
4
Solved
How do I define async fixtures and use them in async tests?
The following code, all in the same file, fails miserably. Is the fixture called plainly by the test runner and not awaited?
@pytest.fi...
Maryammaryann asked 20/4, 2018 at 7:53
4
My code is as follows:
import asyncio
import aiohttp
urls = [
'http://www.163.com/',
'http://www.sina.com.cn/',
]
async def get_url_data(u):
resp = await aiohttp.ClientSession().get(url=u)
he...
Imbibition asked 8/9, 2017 at 9:14
12
Solved
How can I create a wrapper that makes celery tasks look like asyncio.Task? Or is there a better way to integrate Celery with asyncio?
@asksol, the creator of Celery, said this::
It's quite comm...
Bowerman asked 2/10, 2016 at 9:51
3
Solved
(The following code can be run in Jupyter.)
I have a class B, which uses class A, needs to be tested.
class A:
async def f(self):
pass
class B:
async def f(self):
a = A()
x = await a.f() # ne...
Flinty asked 5/2, 2022 at 4:59
3
Solved
I'm working on a small discord bot for a server I made, however I've run into a problem. Whenever I try to run the bot (using python3.4 lilac.py), I get the following error:
Traceback (most recent...
Numbing asked 26/8, 2017 at 4:51
1 Next >
© 2022 - 2024 — McMap. All rights reserved.