Skip to main content

All Questions

1 vote
3 answers
98 views

Asyncio future, running Future objects

I have a code: import asyncio as aio async def coro(future: aio.Future): print('Coro start') await aio.sleep(3) print('Coro finish') future.set_result('coro result') async def main(): ...
IzaeDA's user avatar
  • 397
0 votes
0 answers
40 views

PyQt5 Application with PythonTelegramBot (PTB) coroutine

I'm struggling with running python-telegram-bot-21.10 as a coroutine to a PyQt5 application using Python-3.12.7 (intended to run on a Raspberry Pi). I had this setting operating for some years now ...
blue14's user avatar
  • 56
0 votes
1 answer
177 views

Run multiple async blocking functions simultaneously - Python

I am new to Python and coroutines, I am trying to leverage Python's asyncio library to parallel process a blocking function. I am using python 3.8.6. I have a blocking function that takes in a ...
Shreyas Kulkarni's user avatar
1 vote
1 answer
542 views

Python Warning: Coroutine 'create_task' is not awaited

I am using Python and PyCharm, I am trying to offload database writing using asyncio but am having trouble with IDE warnings In my main.py I start up tasks in this manner db_logging_monitoring_task = ...
Vanillaice's user avatar
1 vote
3 answers
1k views

Run an async function from a sync function within an already-running event loop

In my Python application, I have a sync function boo() that is called inside a running event loop. boo() has to get some data from foo(arg1, arg2), which is an async function. Unfortunately, I can't ...
Ido's user avatar
  • 420
1 vote
1 answer
1k views

Replacement for deprecated asyncio.get_event_loop()

A script I am upgrading uses asyncio.get_event_loop(), which is deprecated since Python 3.12. Asyncio documentation recommends using asyncio.get_running_loop(), which is considered more stable because ...
AmericanJael's user avatar
1 vote
1 answer
187 views

asyncio call_soon: mixing blocking and non blocking calls

I'm going through asyncio in Python, writing random snippets to teach myself how things work. I stumbled on a behavior that I do not understand and am hoping someone can shed some light on this. Let's ...
Charlie Shuffler's user avatar
1 vote
3 answers
3k views

Starting or resuming async method/coroutine without awaiting it in Python

In JavaScript (and other languages) an async function is immediately executed upon its invocation until the first await is encountered. This is not the case in Python. From the asyncio documentation: ...
MaPePeR's user avatar
  • 979
0 votes
1 answer
1k views

When is asyncio.Lock() needed?

Here is the code I have so far that uses the bleak package to connect to multiple Bluetooth devices and get data/notifications from them. The devices are scales are they automatically shut off after ...
user173729's user avatar
0 votes
1 answer
712 views

How to run multiple periodic coroutines without blocking?

I'm writing a python script that checks the uptime of a few domains every few minutes. I run a coroutine for each website in a while loop and sleep them after the check is done. This works, however I ...
fam's user avatar
  • 93
-1 votes
2 answers
236 views

How to create better coroutines in Python [duplicate]

I want to create two asynchronic functions, and I don't know when I will need to run any of them, but they have to not interrupt each other import asyncio async def func1(): await asyncio.sleep(1) ...
evgehatop213's user avatar
1 vote
1 answer
518 views

python asyncio `loop.create_task` add task in another thread's loop, the task randomly get stucked

console's output the code: import asyncio import time from threading import Thread import threading loop = asyncio.new_event_loop() def print_ids(s, l): print(f"{threading.current_thread()....
ogios's user avatar
  • 65
1 vote
1 answer
4k views

How to return the results from a coroutine object with asyncio?

I'm attempting to learn how to run asynchronous code in google co-labs with asyncio. However, I am having issues returning the results. An example I set up for myself looks like this: async def main():...
Carl Lennartson's user avatar
0 votes
0 answers
440 views

Django serve views asynchronously

Django 3.2.8 (a relatively old version) @csrf_exempt def xhrView(request, ms, status=200): sleep(ms / 1000) response = HttpResponse( f'{status} DUMMYXHRRESPONSE IN {ms}ms' ) ...
Weilory's user avatar
  • 3,117
1 vote
1 answer
1k views

When can an asyncio Coroutine be interrupted?

THe question is quite simple. I am new to python's asyncio module and coroutines. If I write an async function like import asyncio async def f(): a = 1 b = 2 await asyncio.sleep(10) ...
HerpDerpington's user avatar

15 30 50 per page
1
2 3 4 5
15