Skip to main content
We’ve updated our Terms of Service. A new AI Addendum clarifies how Stack Overflow utilizes AI interactions.
Filter by
Sorted by
Tagged with
1 vote
4 answers
74 views

When does python 3 execute the beginning of a generator function?

Python 3 seems not to execute the beginning of a generator function, from its first line up to the first yield at the time when the function is first called. Python seems to defer the initial ...
dakra137's user avatar
  • 170
0 votes
0 answers
90 views

boost::asio::io_context stops running new tasks

I'm encountering an issue with the Boost.Asio library. My program uses a single io_context instance and multiple worker threads that call io_context::run(). Tasks are posted using spawn or post on the ...
Zohar81's user avatar
  • 5,214
0 votes
0 answers
124 views

Inquiry: _invoke() Hangs When Executing Query with Dify Plugin SDK

Inquiry: _invoke() Hangs When Executing Query with Dify Plugin SDK I'm currently developing a plugin using the Dify Plugin SDK that connects to a database, executes a query, and returns the result. ...
Bum Su Kim's user avatar
0 votes
0 answers
27 views

Change generator invocation to get rid of subgenerators

I am trying to upgrade my code currently using azure durable-functions library from 1.5 to 2.0. As a part of the change, I would to get rid of the subgenerators usage. Currently, my code is written as:...
Igor Shmukler's user avatar
1 vote
0 answers
78 views

Utility of yield keyword in f sharp

So far I know, we use it mostly for list/array comprehension. Here is two codes: [ for x in range do (yield expression)] else we can also drop the yield and still it works [ for x in range do ...
Clemens Bartholdy's user avatar
-1 votes
3 answers
174 views

Is it possible to use 'foreach' on the same IEnumerable twice or more inside a method with 'yield'?

Very simple case: I have a list of items (1, 2, 3, 4, 5, 6, 7, 8, 9, 10). I need to filter it and drop a few first elements and a few last elements and to get a few items from the middle (for example ...
Andrew's user avatar
  • 33
0 votes
0 answers
62 views

I am yielding to an ERB file, but it is rendering in plain text and not HTML. Why?

<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0&...
Ian Lewis's user avatar
2 votes
2 answers
225 views

How to access the last value in an async generator after a for await...of?

When using for await...of to iterate over an async generator, the final value (return value) seems to be consumed and inaccessible afterward. Here's a minimal example: async function* exampleGenerator(...
Ron Zano's user avatar
  • 642
2 votes
1 answer
62 views

The yield command will not work as it should in Ruby

In the book "The Well-Grounded Rubyist" edition 3 on page 185 is the code. And the code for my_each is on page 183. It also involve code on page 184: Class Array # Put the definition of ...
Retufom's user avatar
  • 21
0 votes
0 answers
33 views

When will the lazy execution of a ParDo in Apache Beam Python be executed?

I'm wondering when would a generator value be evaluated when running in a beam pipeline and how the distributed computing would work in this case as the documentation for ParDos does not really ...
unitrium's user avatar
0 votes
0 answers
68 views

Linux real-time kernel frequently kills my app

I'm developing a near real-time application, that forwards messages in a endless loop(no yield, no sleep, no wait). The messages come from shared memory, go to another blocks of shared memory, so my ...
Leon's user avatar
  • 2,165
2 votes
2 answers
72 views

Python - Generator not working with next method

I created a generator to perform pagination on an api: def page_helper(req, timeout=5, page=1, **kwargs): print(f"Page {page}", end="\r") try: response = req(params=...
Jeroen Vermunt's user avatar
0 votes
1 answer
81 views

How to force a stateful widget to redraw when setting state from within a "yielding stream" listener?

Nothing crazy what I am trying to achieve but I pull my hair on it for days. I basically want to achieve the following: a long running process does internet accesses and processing of data with many ...
Stéphane de Luca's user avatar
0 votes
1 answer
53 views

Python skips recursion if yield is present

I have the following XML file: <?xml version="1.0" encoding="UTF-8"?> <xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2" xmlns:okp=&...
monopoly's user avatar
  • 676
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: ...
ERJAN's user avatar
  • 24.6k
-1 votes
1 answer
48 views

how to generate correct output using 2 yield statements in coroutine?

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: ...
ERJAN's user avatar
  • 24.6k
0 votes
1 answer
54 views

How to yield only newly generated text

I have a Flask application that uses a RAG pipeline in the background, and I stream responses from vLLM. I'm currently using a function to parse and yield the streamed JSON responses. However, I'm ...
Cihan Yalçın's user avatar
0 votes
1 answer
109 views

ensure connection inside generator function is closed by caller [closed]

Today, while programming, I found myself managing a resource (ssh connection) inside a generator function, something similar to the following: #I decided to use a generator to avoid looping through ...
Afelium's user avatar
  • 65
1 vote
1 answer
255 views

Simplest way in C# to defer task execution without synchronization context [closed]

Inside an async method in C#, I need to defer the execution (return the execution to the caller), and also to clear the synchronization context before proceeding with the execution. The statement ...
Ricardo Rocha's user avatar
1 vote
3 answers
312 views

Issues in Streaming response from flask-smorest

I'm encountering issues in streaming response in flask-smorest. I'm following the guidance here - https://flask.palletsprojects.com/en/2.3.x/patterns/streaming/ for streaming responses from my flask-...
FahdS's user avatar
  • 59
1 vote
2 answers
155 views

pytest fixture _cleanup_data not printing expected message (Don't run cleanup section)

I'm having an issue with a pytest fixture in my Python code. The fixture is supposed to print a message after cleaning up test data, but the message is not being printed. I've checked the code and the ...
Safa's user avatar
  • 198
0 votes
1 answer
63 views

Python, Tkinter: Apply delay to function inside generator

I am making an application in python tkinter to visualize algorithms. I want to apply a delay (window.after()) to the function partition() called inside quick_sort. The window.after() seems to only ...
user avatar
-1 votes
1 answer
68 views

Surprising result with a conditional `yield` [duplicate]

I have the following Python code using yield: def foo(arg): if arg: yield -1 else: return range(5) Specifically, the foo() method shall iterate over a single value (-1) if its ...
olebole's user avatar
  • 593
0 votes
1 answer
85 views

Python SciPy differential_evolution yield progress

I am using SciPy differential_evolution to solve an optimization problem. I have a web application that I want to show the progress in. What would be a good technique for giving intermediate feedback ...
simonmarien's user avatar
1 vote
3 answers
282 views

Redefine input function in Python to yield a value from a predetermined list of values each time it's called

Is there a clean "Pythonic" way to write an input-replacement function in Python that will yield a value from a predetermined list of input values each time it's called? raw_data = ['8', '2',...
Eric D's user avatar
  • 1,473
0 votes
0 answers
106 views

Why does delay() suspend a coroutine but yield() doesn't, inside Kotlin's runTest{} function?

The simplified test below has been converted from using runBlocking to runTest to make it work with Kotlin Multiplatform. However, runTest causes it to fail. Debugging shows that the delay in job1 ...
Jimbroze's user avatar
0 votes
2 answers
466 views

Is it possible to yield one compressed file at a time in FastAPI into a single archive using StreamingResponse?

I have code that creates a zip archive of files and streams it. The problem is, for large requests, this means there can be minutes of processing time before the data is streamed, making cancelling ...
Adam's user avatar
  • 31
-1 votes
1 answer
115 views

Batch from yield don't start up concurrently

I'm currently trying to implement a file searcher that yields found files in batches so it can get processed concurrently. But my problem arrives when it yields and I pass it to a task. It never ...
uk3ndt's user avatar
  • 65
1 vote
1 answer
108 views

Python - reverse nested dictionaries dict in dict

I am trying to reverse dictionary nesting such that dict2 in dict1 becomes dict1 in dict2. For this, I followed the method from the link: Pythonic Way to reverse nested dictionaries This dictionary ...
user23174060's user avatar
1 vote
1 answer
99 views

Is it pythonic to put return after yield? [closed]

Consider the following code: def some_gen(): if some_condition: yield "Condition" return for ....: yield some_value 'return' after 'yield' hurts my eyes, is ...
tomekd's user avatar
  • 41
-2 votes
3 answers
64 views

Why this python code is giving two different outputs for the same code or both are different codes? [duplicate]

This is Python code to print Fibonacci series using generator function. Code 1: def test_fib(n): a = 0 b = 1 for i in range(n): yield a a = b b = a+b #end of ...
CKJ_1630's user avatar
1 vote
1 answer
100 views

How to make an asynchronous principle of task execution from a task generator?

I have a problem, do you have any ideas for a solution? You need to add asynchronous tasks to the event loop without waiting for them to be completed (using await is not an option, otherwise there is ...
aero.exe's user avatar
0 votes
0 answers
32 views

How to add a function with generator so that it selects certain strings php

I have a function with string output that outputs a sign in line 5. How to using a generator to add a function that will output line-by-line data from the first variable, where a new line is defined ...
Bay's user avatar
  • 1
1 vote
1 answer
68 views

Latency from sequential yield calls in python

I'm writing a code to read a set of pandas.DataFrames stored in h5 files and iterate over their rows. The aim of my code is to handle the dataset using a pytorch IterableDataset, but I belive my ...
spontiak's user avatar
0 votes
1 answer
39 views

Yield and revenue optimisation of a field: Can Timefold calculate that?

Here is a real life scenario and I wanted to know if TimeFold is relevant for that: I would like to maximize the yield over years of a land to be planted with 2 species of olive trees. I have 2 ...
Akram Ben Aissi's user avatar
0 votes
0 answers
204 views

why is GeneratorExit raised by this combination of yield & exception suppressing ContextDecorator?

My goal is that instead of writing for item in items: with MyCD(): ... # processing logic I would like to have a single line for item in MyCD.yield_each_item_wrapped(items): ......
zsepi's user avatar
  • 1,662
0 votes
1 answer
302 views

Enumerable.SelectMany throws Error CS0411 - cannot be inferred from the usage

I'm using c#, .net 6.0 I'm trying to convert IEnumerable method and ot's caller method to work asynchronously. I have a code that looks something like that: public IEnumerable<MyUser> ...
Amir M's user avatar
  • 560
0 votes
2 answers
114 views

How can I convert IEnumerable method to work asynchronously [duplicate]

I'm using c#, .net 6.0 I'm trying to convert IEnumerable method and ot's caller method to work asynchronously. I have a code that looks something like that: public IEnumerable<MyUser> ...
Amir M's user avatar
  • 560
1 vote
2 answers
136 views

Kotlin yield example

I am learning Kotlin and for the love of it, I cannot get the yield/sequence straight. Could someone please correct my code? fun Sequence<Int>.mapIterable(transform: (Int)->Int) = sequence { ...
ArekBulski's user avatar
  • 5,218
0 votes
1 answer
149 views

How to mock.patch a class method which is a generator/has yield

How to patch a generator class method. For e.g. in class below, how would we patch get_changed_diff_patch method? class PassiveJsonMixin(JsonMixin): """ passive items that do ...
Kabira  K's user avatar
  • 2,065
0 votes
2 answers
95 views

call a new function without closing the file

I have a method that opens a csv file and another method that I want to use to process this file -but I also need it to process different types of objects, so I want to keep it as an independent ...
invalid syntax's user avatar
0 votes
1 answer
149 views

Simpy - service time dependent on length of queue and resources availability

I want to modify this code to solve the following problem: Lets say we have two nurses. If both nurses are free then a patient can use both nurses and the treatment time is cut in half. A patient can ...
user_42's user avatar
-1 votes
1 answer
73 views

Python - Class Content manager. Why __exit__ method is omitted if you put yield inside of it?

class OracleConnected(): def __init__(self): self.oracle_username = oracle_username[1] self.oracle_password = oracle_password[1] self.dsn = cx_Oracle.makedsn(hostname[1], ...
Денис Торопов's user avatar
0 votes
1 answer
72 views

How to catch a yield in a generator without having unused variable? [closed]

I have a warning 'res' is assigned a value but never used no-unused-vars with code similar to this: function* cancelCredit(action) { const res = yield call(/*Nice api call 1*/); const res2 = ...
Laurent Lyaudet's user avatar
2 votes
5 answers
78 views

Converting list function to generator using yield

I am trying to convert a for loop into an iterator using yield, but I have failed in my attempts. I don't understand exactly why the yield isn't giving me the expected output. Does anyone know what ...
oskros's user avatar
  • 3,345
0 votes
1 answer
69 views

How to write a simple function in Julia similar to a function with yield keyword in python

I have a very simple function to illustrate yield keyword in python: def simpleFun(): yield 1 yield 2 yield 3 x=simpleFun() print(x.next()) print(x.next()) print(x.next()) which ...
Vinod's user avatar
  • 4,378
1 vote
1 answer
589 views

Is "yield await" redundant in JavaScript async generator functions?

Promises yielded within async function* declarations seem to be automatically awaited before the iterator result is sent to the caller (source: MDN). Does this mean that yield await somePromise is ...
jmartinezmaes's user avatar
0 votes
1 answer
57 views

@yield not Displaying on Screen

I just started learning Laravel framework in order to start a new project. However, I have encountered a problem where the @yield function does not display the section on the screen. However, if I put ...
newbietypez's user avatar
1 vote
2 answers
1k views

Can yield from a context manager (or similar) multiple times after exception?

I'd like to report multiple errors while processing a list: For example: with MultipleExceptions.testItems(items) as value: ... process value if value==3: raise Exception("3 err") ...
user48956's user avatar
  • 15.9k
0 votes
1 answer
94 views

What does the "yield" keyword do in the code provided? It generates a generator object but behaves differently in a loop [duplicate]

This question is with reference to this [Stackoverflow][1] post about the keyword "yield". I understand that if there is a "yield" statement in the function, the function is called ...
Vijith Kumar V's user avatar

1
2 3 4 5
37