Questions tagged [coroutine]

Coroutines are a general control structure whereby flow control is cooperatively passed between two different routines without returning.

1
vote
0answers
16 views

Why we could not catch Stopiteration exception in a generator definite function?

def simple_generator(): print("-> start ..") try: x = yield print("-> receive {} ..".format(x)) except StopIteration: print("simple_generator exit..") I know ...
1
vote
1answer
26 views

Python traceback for coroutine

Let's say I have the following code: from types import coroutine @coroutine def stop(): yield 1 async def test2(): await stop() async def test1(): await test2() await test2() # ...
0
votes
1answer
12 views

Using CoRoutine Unity 3D Buttons

I'm currently making a quiz game that has three buttons, from an object pool, and I want them to turn green or red depending on whether or not they are the correct answer. This works perfectly. When ...
0
votes
1answer
34 views

Coroutines and triggers

My problem is that I'm making a game with unity, and what I want to do is when the enemy in my game hits the obstacle, it does x damage every one second. There's a collider and health script on the "...
0
votes
1answer
23 views

Passing coroutine function as function parameter

I need to pass a coroutine function as a parameter for another function. For example: private fun handleIt(here: Long, call: (hereId: Long) -> Unit) { call(here) } and then from the ...
0
votes
1answer
17 views

How to properly replace @pytest.mark.gen_test after pytest upgrade to 4.0.2?

I have tornado co-routines tests that passed under pytest 3.8.2, but recently I've upgraded to 4.0.2 and now I get these tests failed with the following message. @pytest.mark.tryfirst def ...
0
votes
1answer
40 views

Which is better to put the Coroutine call in the Repository or the ViewModel?

Just wondering others opinion I have 2 ways I can go about doing something and was curious which is better (and hopefully why you think so) I have 2 files WordRepository and WordViewModel. I can ...
1
vote
1answer
54 views

starting Coroutine gives null reference exception in unity

I am trying to access a Coroutine from my GameController.cs script, the Coroutine is located in my DatabaseManager.csscript. I am trying to access the Coroutine like this: DatabaseManager d1 = new ...
5
votes
1answer
80 views

boost::coroutine2 vs CoroutineTS

Boost::Coroutine2 and CoroutineTS(C++20) are popular coroutine implementations in C++. Both do suspend and resume but two implementations follow a quite different approaches. CoroutineTS(C++20) ...
-1
votes
2answers
52 views

roation on trigger oculus go c# unity

I'm looking to have a game object rotate when the trigger on the oculus go is pressed but only then, I have the following code. Unfortunately this continuously roates even when I take my finger off ...
0
votes
0answers
23 views

Unit testing randomly fails with coroutines

I'm having a problem with my unit tests randomly failing due to, what I believe is, race conditions in the coroutines. I have a class which some dependencies that are mocked in my UT. (I have used ...
3
votes
1answer
63 views

Can a Python coroutine be implemented without await or yield?

I'm learning Python await / async syntax and wondering how coroutine can be implemented without async, await or yield. For example, I made this simple three seconds timer with async def syntax: ...
3
votes
0answers
54 views

Pipelines with asyncio coroutines

I'm new with asyncio and I'm implemented some kind of pipeline using asyncio coroutines. The main idea is to have different pipelines with coroutines that are connected to aggregate information in a ...
1
vote
1answer
44 views

Blocking the main thread on Android while doing task asynchronously

I've been struggling to understand the difference between multi threading v asynchronous programming on Android. Mainly, why a long running task needs to be taken off the main thread, even if that ...
1
vote
2answers
77 views

Kotlin - coroutine yield() what is its purpose?

I'm not exactly sure what is the purpose of the yield function. Can you check this example I have? I am following an example here but anyway. Here is the code: val job = launch { val child =...
0
votes
0answers
27 views

Values not received from Coroutine's Channels

My code-flow is the following: SqlDelight queries ( 2x ) -> Coroutine Channels ( 2x ) -> Coroutine Channel ( 1x ) I noticed that the Queries' Channels are emitting, Presenter's is receiving and its ...
1
vote
1answer
47 views

Boost ASIO and co_await- use with any third party callback?

A simple function: awaitable<std::size_t> write(const std::vector<uint8_t>& data) { auto token = co_await this_coro::token(); return co_await async_write(serialport_, buffer(...
2
votes
1answer
36 views

Will Kotlin coroutine always run on same thread? If not then how can we make it work with Guice Request Scope semantics?

Request scope enables us to track request wise variables throughout the request processing. But I think it depends on thread local variables. I assume using Kotlin coroutines will that break the Guice ...
0
votes
1answer
28 views

Trying to make a reload delay in c# yet running into a bug

So I have been trying to make a game recently and I have ran into a unexpected bug. As I run the script I have wrote I can shoot 10 bullets out of my gun, then it plays a reload sound and waits two ...
3
votes
1answer
49 views

Kotlin coroutines - start another task if after some time the first one doesn't finish

I am using Kotlin coroutines to get data from the server, I am passing the deferred over to other functions. In case the server doesn't give an answer in 2000 ms I would like to retrive the object ...
1
vote
2answers
37 views

Lua debug hooks seems to prevent the coroutine from working

So, I'm trying to build a multitasking system in lua that hands control back to the main thread at regular intervals. The issue is that debug.sethook seems to cause the coroutines to die immediately ...
2
votes
2answers
79 views

Kotlin Coroutines : Waiting for multiple threads to finish

So looking at Coroutines for the first time, I want to process a load of data in parallel and wait for it to finish. I been looking around and seen RunBlocking and Await etc but not sure how to use ...
1
vote
1answer
51 views

Coroutines running on the main thread instead of background

I have an application in which user picks a pdf from file explorer and then I need to convert that pdf to base 64. Following is my code to convert pdf to base64 private fun convertImageFileToBase64(...
0
votes
1answer
50 views

Coroutine Not wokring correctly: only one object is fading in

Many thanks for your reply. I've just updated the code. There does Seem to be a problem with wholeRenderer.materials[i].color = Color.Lerp(wholeFadeInColors, wholeFadeOutColors, lerpFactor);. Errors ...
0
votes
1answer
31 views

How does Python interpreter implement coroutine

Currently, I'm trying to understand how Python implements yield and generators. On the documentation it says By suspended, we mean that all local state is retained, including the current bindings ...
-2
votes
1answer
38 views

coroutine not wokring correctly

Hi Having trouble with the following coroutine part of my script in c#. The error message I get is attached in the screen grab, seems to be the: GetComponent<Renderer>(). using System....
4
votes
1answer
109 views

How to implement non-blocking infinite loop in Python

I have an infinite loop that reads video frames from webcam and each frame will go through a complex function that requires high computing power. So when displaying the frames the program will feel ...
2
votes
2answers
48 views

Coroutines the proper way to add a job as child of another?

Given we have job1 : Job and job2 : Job and we want to make job2 a child of job1 (they where created separately have no relation). What is the correct way to declare that relationship? so that when ...
1
vote
2answers
56 views

Runnable.Run / StartCoroutine calles to Watson services from Unity

In my ExampleStreaming.cs script, once the user utterance is recognized as final, I send it to both the Watson Assistant service and the Tone Analyzer. Because I am keeping the scripts for each ...
0
votes
3answers
113 views

Update UI async call with coroutines

I've got to update the UI with an async call to the Room Database, but when I do I've got this error : android.view.ViewRootImpl$CalledFromWrongThreadException: Only the original thread that created a ...
-1
votes
2answers
71 views

How to continue the function only after the coroutine completes?

void Generate() { StartCoroutine(FallDelayCoroutine()); print("time3- " + Time.time); } IEnumerator FallDelayCoroutine() { print("time1- "+ Time.time); yield return new ...
1
vote
1answer
49 views

Scanner and parser interaction

I am new to flex/bison. Reading books, it seems that in nearly all compiler implementations, the parser interacts with the scanner in a "coroutine" manner, that whenever the parser needs a token, it ...
0
votes
1answer
109 views

Android viewmodel coroutine pattern

I would like to hear some critics on the way I have implemeneted viewmodel data fetching using coroutine. My goal is clean way to write ViewModels. But isn't it too big of overhead? I haven't found so ...
0
votes
1answer
25 views

unity run function from coroutine

hi why dosn't this work i'm trying to rotate a game object from a cororotine the function runs but not the rotate if i put the rotate in the update it runs fine im confused thanks for any help ...
0
votes
1answer
77 views

Kotlin coroutines get results from launch

I'm new to kotlin and its concept coroutine. I have below coroutine using withTimeoutOrNull - import kotlinx.coroutines.* fun main() = runBlocking { val result = withTimeoutOrNull(...
0
votes
1answer
41 views

Event loop in asyncio is overflowing. Though adding 4 executions at a time it is overloading

In the following code I am calling getSUEPEvent() funtion 4 time for single loop. I restart loop again for next 4. Still execution keeps on adding to loop. If loop is global than can any one suggest ...
0
votes
2answers
47 views

How to set variable inside of a Coroutine after yielding a webrequest

Okay I will try and explain this to the best of my ability. I have searched and searched all day for a solution to this issue but can't seem to find it. The problem that I am having is that I have a ...
0
votes
1answer
58 views

Get arraylist in JSON

My JSON looked like this {"status":true,"error_message":[],"locations":[{"id":"12","name":"office"},{"id":"13","name":"home"}]} I'm using coroutine and retrofit to communicate with web service. I ...
0
votes
1answer
29 views

Unity Move 3D object Within a barrier

I am using the code below attached to a cylinder object with ridge body and collision. This object is placed in the middle of collision barriers that form a circle. I am trying to get this object to ...
0
votes
1answer
125 views

Coroutine yield return null [duplicate]

This is my first question.. I learning how to make games using C# and Unity so I came across Coroutines and I know how these methods work but there is one thing that I didn't understand which is: ...
1
vote
0answers
31 views

Why is this script for a “Heating Aura” not working? Unity 2D C# [duplicate]

I'm using Microsoft Visual Studio. I've been trying to make a "heating" script for an empty sprite with a CircleCollider2D, but everything I do doesn't work. I made a Freezing script so that the ...
1
vote
1answer
98 views

Coroutines on F# that yields a value

I want to better understand continuations and coroutines. I want to code them without using seq or async workflows. I've found several implementations of Coroutines in F# this simple coroutines, and ...
0
votes
2answers
67 views

How to get the name of a coroutine in Kotlin?

I'm curious about the internal working of a coroutine when suspended on the main thread. The real question is how to log a suspended function which is a coroutine on the main thread. Where exactly the ...
0
votes
2answers
62 views

coroutines vs classes in python

My question is a very broad one. Why would one use coroutines when one can use objects? I could easily implement an iterator that works only once under next() and after that you have to call o.send(x)....
0
votes
2answers
269 views

Unresolved reference: async in Kotlin in 1.3

I have multi module kotlin gradle project in github here. One of my sub project introducing-coroutines with build file build.gradle.kts file is here The contents of build.gradle.kts is - import ...
0
votes
0answers
31 views

What is the replacement for CommonPool in the coroutine release?

I have migrated to the new kotlin and coroutine version, I have refactored most of my code. However, I can't seem to find the replacement for CommonPool in the new coroutine release. Does anyone have ...
3
votes
1answer
58 views

How to detect the completion of a Tcl coroutine?

I'd like to find a nice way in Tcl to detect the end of a coroutine. Consider: coroutine cor apply {{} { yield 1 yield 2 yield 3 }} try { puts [cor] puts [cor] puts [cor] ...
1
vote
1answer
104 views

kotlin GlobalScope, runBlocking is not available in kotlin.coroutines.*

I have multi module kotlin gradle project in github here. One of my sub project introducing-coroutines with build file build.gradle.kts file is here The contents of build.gradle.kts is - ...
0
votes
2answers
75 views

Non-blocking launching of concurrent coroutines in Python

I want to execute tasks asynchronously and concurrently. If task1 is running when task2 arrives, task2 is started right away, without waiting for task2 to complete. Also, I would like to avoid ...
-1
votes
2answers
79 views

why is yield not returning 11?

i cant figure out why my generator is not returning value =11, here is my code: def monG(borneinf,bornesup): while True: if bornesup < borneinf: bornesup, ...

http://mssss.yulina-kosm.ru