Oct-31-2022, 01:25 AM
if a generator spawns a thread, what happens? can 2 or more threads do yields in the same generator? what if 2 or more threads try to iterate the same generator?
(Oct-31-2022, 05:47 PM)Skaperen Wrote: [ -> ]it could be a good way to spread a work queue to many threads.Your question looks like an instance of a XY problem. The description is very vague: it depends on such and such....
(Oct-31-2022, 09:23 PM)Gribouillis Wrote: [ -> ]Try to describe a simple problem that you want to solve with threads and why you think using thread-friendly generators is the solution.launch a subprocess and feed data to it over a pipe to its stdin while concurrently receiving data from its stdout over another pipe. maybe also receive stderr. a function to do this handles all but stdout by processing data to/from some kind of buffer (list, bytearray) and for the process stdout, this function will yield a line at a time. the caller gets the generator instance to get that output from. i'm developing a function to run processes and am exploring all the ways to handle data and work with callers.