Skip to main content

All Questions

9 votes
1 answer
6k views

Python Asyncio errors: "OSError: [WinError 6] The handle is invalid" and "RuntimeError: Event loop is closed" [duplicate]

I am having some difficulties with properly with my code, as I get the following error after my code finishes executing while debugging on VSCode: Exception ignored in: <function ...
2 votes
0 answers
2k views

How can ib_insync reqHistoricalDataAsync work with Asyncio?

import asyncio import ib_insync as ibi import symbol_list import time start = time.perf_counter() stocklist = symbol_list.test endDateTime = '20190328 09:30:00' durationStr='1 D' dataDirectory = './...
1 vote
2 answers
104 views

How do you make faster API calls using multithreading without using requests in Python?

I'm trying to receive historical stock data for every company in the S&P 500. The problem is that it is taking a really long time to get the data. from ApiStuff import ApiStuff import ...
0 votes
0 answers
32 views

The set_result() of Future doesn't end the await after the loop of create_task()

I write a Python program involving a loop of create_task() that calls async functions. In each task, it waits for another thread to set the result for a Future object. async def run(self) -> int: ...
0 votes
0 answers
17 views

PySimpleGUI - working of two windows at the same time [duplicate]

I have a project using the PySimpleGUI library. The application has many windows. The project is built as follows: def window_nr_2(): layout2 = [[sg.Button ('But A'), sg.Button ('But B')]] ...
0 votes
0 answers
133 views

How to read data from Siemens S7-1500 PLC asynchronously using Python and snap7?

I am trying to read data from a Siemens S7-1500 PLC in an asynchronous way using Python and the snap7 library. My goal is to read multiple tags concurrently. However, I am encountering the error b'CLI ...
14 votes
4 answers
17k views

asyncio: Wait for event from other thread

I'm designing an application in Python which should access a machine to perform some (lengthy) tasks. The asyncio module seems to be a good choice for everything that is network-related, but now I ...
3 votes
1 answer
819 views

Asyncio threadsafe primitives

I need Threadsafe primitives (locking, conditions Semaphore), do they exist in the asyncio ecosystem? I created some code myself, but it feels a bit sluggish: import asyncio from threading import ...
9 votes
2 answers
5k views

Debugging an async program in the pycharm debugger

My request is to get debugging data from the debugger and pycharm prompt: Lets say I have an-old-style python synchronous program with a bug: def listdir(self, remote_path): with ssh....
0 votes
0 answers
66 views

Interface between threaded and asynchronous parts of an application in Python

I'm helping develop a Python application which collects data from several sensors and manages a server to send those data to a web application (React) to display. The application is supposed to work ...
0 votes
0 answers
226 views

await asyncio.to_thread blocks complete event loop?

I am trying to create a Python program that - when triggered via a websocket - does some blocking work in a thread. I would expect my program to be able to continue to react to the stop signal also ...
0 votes
1 answer
79 views

Python asyncio: Do I Need Synchronization Primitives for Shared Variables When Using run_in_executor with ThreadPoolExecutor?

I'm working with Python's asyncio and triing to understand the run_in_executor function with the default ThreadPoolExecutor to handle blocking tasks asynchronously. My concern is regarding accessing ...
1 vote
2 answers
134 views

How to call an async function from a child thread using asyncio.run_coroutine_threadsafe() and the main thread's loop? [duplicate]

I have an application that runs using async/await everywhere. Often, it calls out to functions that are synchronous. Those functions sometimes have to call asynchronous functions again. I am trying to ...
19 votes
3 answers
27k views

How to send server-side events from python (fastapi) upon calls to a function that updates the backend state

I have the following problem: given a backend running fastapi, that has a streaming endpoint, which is used to update the frontend, I want to send these updates every time the function that updates ...
1 vote
0 answers
489 views

How can I run/start an async periodic task in the background in FastAPI [duplicate]

Assuming to have a list of Callable async tasks and I wish to run them in a background with a periodic timing. How can I design this with FastAPI? In my toy example I tried the BackgroundTasks but as ...

15 30 50 per page
1
2 3 4 5
14