concurrency

How to increase asyncio thread limits in an existing co-routine

How to increase asyncio thread limits in an existing co-routine Question: I am currently working on a program using concurrency with asyncio. The code here is over simplified in order to show the problem. It is runnable without any dependencies if you need so. You have two tasks levels: 1: One in operation_loop which creates …

Total answers: 1

How to run several python scripts in one file concurrently?

How to run several python scripts in one file concurrently? Question: I want to run several python scripts from the main file and make them work in parallel. I would like to print their outputs in a console if it is possible. It’s better to run them in different processes to be able to operate …

Total answers: 1

python using concurrent futures to read file asynchronously method guidance

python using concurrent futures to read file asynchronously method guidance Question: I want to add concurrency.futures module asynchronous I/O reading to my script. I want file to be read one time, then the result to be worked on. As logic of module does not align with it I created two different functions which separately reads …

Total answers: 1

Release redis lock if process die

Release redis lock if process die Question: I’m using redis distributed locks to make sure some celery tasks don’t run concurrently. For managing locks with redis I’m using the python redis library version 4.0.0 (which specifies that any deadlock problems should be handled by the programmer). Since I would like to avoid using the timeout …

Total answers: 1

Python Parallel plotting and and input reading

Python Parallel plotting and and input reading Question: I am seeking help with understanding why multithreading does not work correctly in this example: import time import matplotlib.pyplot as plt import concurrent.futures voltage = list() stop_flag = False fig, ax = plt.subplots() fig.show() def plotter(ax, arr): while True: if stop_flag: print("stream interupted") return arr.append(1) ax.clear() ax.plot(arr) …

Total answers: 1

Managing contents of defaultdict with concurrency in python

Managing contents of defaultdict with concurrency in python Question: Some questions have looked at non-nested defaultdict behavior when multiprocessing: Using defaultdict with multiprocessing? Python defaultdict behavior possible with multiprocessing? and it seems that managing something nested like defaultdict(list) isn’t an entirely simple process, let alone something more complex like defaultdict(lambda: defaultdict(list)) import concurrent.futures from collections …

Total answers: 1

How to combine parallelization and concurrency in a single python library?

How to combine parallelization and concurrency in a single python library? Question: I want to speed up my code by using concurrency and parallelization within one library using Python. My current set up goes in single thread: – input a, b, c – downloading data into a list: data = [downloadedData(a), downloadedData(b), downloadedData(c)] – transforming …

Total answers: 1

How do I get Python to send as many concurrent HTTP requests as possible?

How do I get Python to send as many concurrent HTTP requests as possible? Question: I’m trying to send HTTPS requests as quickly as possible. I know this would have to be concurrent requests due to my goal being 150 to 500+ requests a second. I’ve searched everywhere, but get no Python 3.11+ answer or …

Total answers: 3

Python ThreadPoolExecutor: How to evaluate what caused a timeout

Python ThreadPoolExecutor: How to evaluate what caused a timeout Question: Given the following simple method that causes a TimeoutError at some point. How can I determine what were the conditions (e.g. arguments or something else) that caused the timeout? In [82]: def f(i): …: print(i) …: if i == 2: time.sleep(1) …: return "done" …: …

Total answers: 1

How to do a "real concurrent" corroutines

How to do a "real concurrent" corroutines Question: I’m trying to do this: "An event loop runs in a thread (typically the main thread) and executes all callbacks and Tasks in its thread. While a Task is running in the event loop, no other Tasks can run in the same thread. When a Task executes …

Total answers: 1