2,397 questions
1
vote
4
answers
96
views
Why only creating a task will run the coroutine in python?
There is something I can't understand in this code
import asyncio
async def fetch_data(param):
print(f"Do something with {param}...")
await asyncio.sleep(param)
print(f"Done ...
5
votes
1
answer
385
views
How to use C++ coroutine with Qt?
I am trying to use coroutines with Qt.
Here's minimal(I guess) example to reproduce my problem
Basically, bellow code is adopted from the example of cppreference here:
https://en.cppreference.com/w/...
2
votes
0
answers
67
views
How can I dynamically trace and visualize memory allocation patterns of nested Python coroutines in real-time?
I'm trying to understand how memory is used in my async Python application. I have multiple coroutines running, and I want to see how much memory each one is using, especially when they are nested or ...
1
vote
0
answers
112
views
Coroutine with RAII using Boost.Asio
I'm writing some test code using Boost.Asio with C++20 coroutines.
Working version (manual cleanup, non-RAII)
The following code works as expected. Cleanup is always called, even when an exception is ...
1
vote
0
answers
90
views
Lua preemptive multitasking and supporting nested coroutines
I am trying to write a scheduler for a virtual computer that runs Lua and is transparent to the user (i.e.; no coroutine. yields needed) and would still like the user to be able to create coroutines ...
3
votes
1
answer
107
views
Are `std::noop_coroutine` and `noop_coroutine_handle` redundant?
In GCC 15, std::noop_coroutine's definition is
{ return std::noop_coroutine_handle(); }
std::noop_coroutine_handle is defined by:
using noop_coroutine_handle = std::coroutine_handle<std::...
-7
votes
1
answer
267
views
Are Cgo implementing functions allowed to arbitrarily manipulate the stack pointer? [closed]
I would like to know whether Cgo implementing functions are allowed to arbitrarily manipulate the stack pointer. The motivation for this is to allow the use of coroutines on the C side of the call. ...
0
votes
1
answer
55
views
Android, how to print out coroutine id or name on a custom log function
I want to modify this log helper function to print out coroutine id or name.
@JvmInline
value class MyLogger(private val tag: String) {
fun log(level: Level, e: Throwable? = null, ...
1
vote
1
answer
93
views
Does the call instruction write something onto the stack? For example, things like environment variables?
I am currently running a C++ program in which I have used the heap to simulate the stack and employed assembly language to place relevant information (such as memory addresses) into registers, thereby ...
1
vote
1
answer
64
views
C++ Profiling - Called method from coroutine function has a higher hit count than its caller
I am profiling some code using the cppgraphgqlgen library - which uses C++20 coroutines extensively in its internals.
I have profiled an application and found that I have some called-into methods that ...
1
vote
3
answers
127
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():
...
0
votes
0
answers
48
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 ...
2
votes
1
answer
55
views
Can Lua define anonymous member functions?
In Lua, I can define a member function like this:
Foo = {}
function Foo:bar()
...
end
I realise this is just syntactic sugar for this:
Foo = {}
foo.bar = function(self)
...
end
Is there a way ...
2
votes
1
answer
117
views
Why do coroutines need less memory than threads?
It is often said that coroutines could be thought of as "light threads" because they consume less memory. However, I wasn't able to find any explanation on why exactly that is the case. What ...
1
vote
1
answer
139
views
how we can pass values to a coroutine
I want to know a method to pass values from the caller to the coroutine.
My idea:
Any awaiter type must provide a await_resume() function. This function can return something to the co_await inside ...
0
votes
0
answers
96
views
Is there a clean way to template match lvalue or value but not rvalue?
So far the best I've come up with is a wrapper function for every function, like this:
template<class A, class B>
coro<var> operator+(A && a, B && b)
{
return [] (A a, ...
2
votes
0
answers
154
views
What's wrong with my implementation of c-style coroutine
I try to implement a simple coroutine using c.
The platform is:
M3 Pro MacBook Pro 16
apple native gcc
macOS 14.3.1
Here is my code:
// main.c
#include <stdio.h>
#include <stdlib.h>
#...
2
votes
2
answers
114
views
c++ coroutine, done() function returns different value in a same loop
godbolt: https://godbolt.org/z/6avWcGqKv
The following code, compiled and run with g++ 12, 13, 14, all give the same (wrong?) output.
clang 18, 19 are fine (all "done: 1").
As far as I ...
1
vote
1
answer
51
views
coroutine_handle::done always returns false
I have a very simple coroutine example to understand basics. However, I am stuck to understand why the done method of the handle object still returns false. I call resume and there is no more co_await ...
0
votes
1
answer
162
views
How to force 2 coroutines never run simultaneously
In this code:
private suspend fun doSthSingleThreaded(){
coroutineScope {
//Coroutine 1
launch {
//do sth that will suspend
}
//Coroutine 2
...
1
vote
0
answers
42
views
Isn't stacking suspend'able functions a performance killer?
While diving into Android/Kotlin development, I learned that the suspend keyword transforms the function into a state machine that can be removed from its executing thread, put on hold, and resumed at ...
1
vote
3
answers
104
views
how to catch throw and other exceptions in coroutine with 1 yield?
I have var DICTIONARY, which is a dictionary where the keys are English letters and the values are words that start with the corresponding letter. The initial filling of DICTIONARY looks like this:
...
0
votes
0
answers
43
views
Function works but coroutine doesn´t
I have a really weird bug where I have a function that resets my whole room. First, it clears the previous grids if they exist. Then, it generates lists of lists of vectors, which work as grids. Then ...
0
votes
1
answer
75
views
How to test SnapshotStateList being updated
I have
class MyViewModel(private val activitiesRepo: ActivitiesRepo) : ViewModel() {
val activities = mutableStateListOf<Activity>()
private var activitiesFlow =
activitiesRepo....
3
votes
1
answer
92
views
Why can't I read from the stdout/stderr of a process spawned with forkpty in the C++20 coroutines + Asio single-threaded multi-coroutine model?
I am new to corotine and asio.
I am working on a local process management tool where a client is responsible for launching a program. This client sends commands to a backend daemon that manages the ...