I’m trying to make sure that several threads start as close to each other as possible, and for that I’m using time.sleep. Each thread will have its own logger, which will output to its unique file. There’s something very strange happening though… Sometimes, not all logger files are created. In the example below, instead of… Read More Using multithreading with time.sleep and unique loggers
I can start function with my own count of threads and it works: start_time = time.time() t1 = Thread(target=time.sleep, args=(3, )) t2 = Thread(target=time.sleep, args=(3, )) t1.start() t2.start() t1.join() t2.join() print("— %s seconds —" % (time.time() – start_time)) Output: — 3.00131893157959 seconds — but I want to input threads number from user, I tried to… Read More How to get count of threads from user and start Thread Python
I’m coding my own Asteroids minigame using pygame (which is extremely inefficient with multiple sprites so wanted to use threading. How do I access a function from another class (asteroids class) through my main class (handler) class. If my class system is backwards or doesn’t work using Threading, please explain to me how I could… Read More How to call class function from seperate class function through Threading module Python
In the first example I am getting output I expect here to be, but I can’t say same about second example. Technically, in both example I have 3 tasks (Just in second example, I am scheduling 2 coros execution from main coro) isn’t it ? In second example, why Event loop does not resume main()… Read More Asyncio getting different outputs
Is there a way to child.py sends stout "on the fly", when running? Or main.py needs to wait child.py to terminate? In these scripts, main.py needs to wait 5 seconds to start printing all lines. I want that process.stdout.readline() get the last print in child.py when child.py still running. main.py import subprocess import time process… Read More python subprocess send stout on the fly when running
I’m trying to share two variables for a comparation in a conditional in my main, but I am getting errors whenever I set the variables as global, saying that the variable was started before global statement. Here is a peek to the code: #thread timer for minute class myMin(Thread): def run(self): global now global timestart… Read More How can I share a variable from a thread to my main in python?