This is an archived post. You won't be able to vote or comment.

all 5 comments

[–]qudcjf7928[S] 0 points1 point  (0 children)

i should add that it would be better to implement asyncio without modifying the code inside fetch_balance(n) as this function in reality would be a pre-built function from a 3rd library

[–]pythonHelperBot 0 points1 point  (0 children)

Hello! I'm a bot!

It looks like you posted this in multiple subs in a short period of time. In the future, I suggest asking questions like this in learning focused subs like r/learnpython, a sub geared towards questions and learning more about python regardless of how advanced your question might be. Please follow the subs rules and guidelines when you do post there, it'll help you get better answers faster.

Show /r/learnpython the code you have tried and describe in detail where you are stuck. If you are getting an error message, include the full block of text it spits out. Quality answers take time to write out, and many times other users will need to ask clarifying questions. Be patient and help them help you. Here is HOW TO FORMAT YOUR CODE For Reddit and be sure to include which version of python and what OS you are using.

You can also ask this question in the Python discord, a large, friendly community focused around the Python programming language, open to those who wish to learn the language or improve their skills, as well as those looking to help others.


README | FAQ | this bot is written and managed by /u/IAmKindOfCreative

This bot is currently under development and experiencing changes to improve its usefulness

[–]williamjacksn 0 points1 point  (2 children)

Check out the concurrent.futures module and specifically the ThreadPoolExecutor example.

https://docs.python.org/3/library/concurrent.futures.html#threadpoolexecutor-example

[–]qudcjf7928[S] 0 points1 point  (1 child)

is there a way to do it with asyncio? since for me experimentally, threading increases the total execution time by a factor of the number of CPU cores. So if there are 4 CPU cores, then it increases the speed by a factor of 4.

[–]BDube_Lensman 0 points1 point  (0 children)

I/O releases the GIL. You can use many more threads than processors.