async-await

Can't connect asynchronously to opcua server

Can't connect asynchronously to opcua server Question: I’m trying to get a value of a node in my OPCUA server. I’m using asyncua on a windows 10 x64 computer. The server is on a PLC. When I write this in a normal task it works client = Client("opc.tcp://192.168.1.88:4840") # client.max_chunkcount = 5000 # in case …

Total answers: 1

Why is not letting me call this async function with await?

Why I'm unable to call this async function with await? Question: This is the web scraping problem that I have encountered that I don’t know how to fix. I want to call the async function scrape_session, but I cannot call it in the main file, and it gives me the error: error: "await" allowed only …

Total answers: 1

asyncio TaskGroup throwing TypeError when returning lists

asyncio TaskGroup throwing TypeError when returning lists Question: I am trying to use the new TaskGroup object in Python 3.11 to return lists, and I am struggling to find the correct syntax. There isn’t much example code out there yet for this new feature, so I figured I’d ask. import asyncio async def squares(nums): return …

Total answers: 1

Cogs TypeError: object NoneType can't be used in 'await' expression in discord.py

Cogs TypeError: object NoneType can't be used in 'await' expression in discord.py Question: I’ve been working on a discord bot for a personal server. I want to use cogs to separate the music player functionality from the main file. I am raising this error when I load my main.py file: discord.ext.commands.errors.ExtensionFailed: Extension ‘cogs.cog’ raised an …

Total answers: 1

Convert Blocking python function to async function

Convert Blocking python function to async function Question: So currently I have 4 api requests which are called in synchronous method using a third_party lib which is synchronous. What i want is to run them in parallel. So that my total time to call all 4 apis is reduced. I am using fastapi as micro …

Total answers: 1

Python/Pyscript asyncio order of events not as expected

Python/Pyscript asyncio order of events not as expected Question: I am calling the code below from HTML using py-script. I am seeing that the order of events in this simple example is not what I expected. In the output below the displayed events are not in sequence. What am I missing to make my code …

Total answers: 1

Python: await the generator end

Python: await the generator end Question: Current versions of Python (Dec 2022) still allow using @coroutine decorator and a generation can be as: import asyncio asyncify = asyncio.coroutine data_ready = False # Status of a pipe, just to test def gen(): global data_ready while not data_ready: print("not ready") data_ready = True # Just to test …

Total answers: 1

Telethon async and await mess

Telethon async and await mess Question: Here is my code as follows: import time import telethon import asyncio # Enter your API ID and API hash here api_id = 13****** api_hash = ‘8ba0a***********************’ # Enter the name of the text file containing the messages message_file = ‘messages.txt’ async def main(): # Connect to the Telegram …

Total answers: 1

Python async function not working when called outside run loop

Python async function not working when called outside run loop Question: I am writing an abstraction layer over a request-response library example. In the original example the request packet is sent to server inside an infinite loop which I have generalized here. from their_stack import create_endpoint async def run(remote_ip, remote_port): server_connection = await create_endpoint(remote_ip, remote_port) …

Total answers: 1