multithreading

parallelization of downloading thousands of files using wget

parallelization of downloading thousands of files using wget Question: I have thousands of the files like below to be downloaded. urls = [‘https://ladsweb.modaps.eosdis.nasa.gov//archive/allData/61/MOD03/2019/001/MOD03.A2019001.0450.061.2019001110251.hdf’, ‘https://ladsweb.modaps.eosdis.nasa.gov//archive/allData/61/MOD03/2019/001/MOD03.A2019001.0455.061.2019001110452.hdf’, ‘https://ladsweb.modaps.eosdis.nasa.gov//archive/allData/61/MOD03/2019/001/MOD03.A2019001.0500.061.2019001110658.hdf’, ‘https://ladsweb.modaps.eosdis.nasa.gov//archive/allData/61/MOD03/2019/001/MOD03.A2019001.0535.061.2019001110116.hdf’, ‘https://ladsweb.modaps.eosdis.nasa.gov//archive/allData/61/MOD03/2019/001/MOD03.A2019001.0555.061.2019001132709.hdf’, ‘https://ladsweb.modaps.eosdis.nasa.gov//archive/allData/61/MOD03/2019/001/MOD03.A2019001.0615.061.2019001132734.hdf’, ‘https://ladsweb.modaps.eosdis.nasa.gov//archive/allData/61/MOD03/2019/001/MOD03.A2019001.0630.061.2019001132950.hdf’, ‘https://ladsweb.modaps.eosdis.nasa.gov//archive/allData/61/MOD03/2019/001/MOD03.A2019001.0635.061.2019001133203.hdf’, ‘https://ladsweb.modaps.eosdis.nasa.gov//archive/allData/61/MOD03/2019/001/MOD03.A2019001.0650.061.2019001132727.hdf’, ‘https://ladsweb.modaps.eosdis.nasa.gov//archive/allData/61/MOD03/2019/001/MOD03.A2019001.0655.061.2019001132653.hdf’] I can download them one by one using wget as follows. #wget is here, https://eternallybored.org/misc/wget/1.21.3/64/wget.exe import os, glob, subprocess import itertools import multiprocessing …

Total answers: 3

How to make a Python threaded program (with Locks) to run on multi-process?

How to make a Python threaded program (with Locks) to run on multi-process? Question: I have a multi-threaded program, and I want to let the user choose how to run them, either in serial, multi threads or multi cores, at least at the top level. A runnable demo is shown below illustrating my program’s logic. …

Total answers: 3

Python threading.Thread : random occurrences of missing final newline of print()

Python threading.Thread : random occurrences of missing final newline of print() Question: I am just in a process of learning how to use the Python threading module and come up with following code which should help me to understand how threading works: from time import sleep from threading import Thread closeAllThreads = False threadCounter = …

Total answers: 1

Python threading daemon error when extending Thread class

Python threading daemon error when extending Thread class Question: I’ve been trying to extend my Thread class to return something from a target function but I want to keep the daemon = True. The default daemon is False so I need to pass the True value into the Thread.__init__() and when I try: __init__() takes …

Total answers: 1

Parallelization of un-bzipping millions of files

Parallelization of un-bzipping millions of files Question: I have millions of compressed .bz2 files which I need to uncompressed. Can uncompression be parallelized ? I have access to the server with many cpu cores for the purpose. I worked with the following code which is correct but it is extremely slow. import os, glob, bz2 …

Total answers: 3

Python multithreading broken

Python multithreading broken Question: I wanted to start learning about threading in python so I grabbed myself a tutorial and started reading and coding. The following code is what I came up with. I created a function wait that is suppoesed to print out "Waiting started" and then go to sleep for 3 seconds befor …

Total answers: 2

Enabling numpy array to be modified by several threads

Enabling numpy array to be modified by several threads Question: So I want to take the minimum of an array and instead of having a single thread do all the work I have several threads populating such array entry by entry (this is an expensive call and can’t be changed) and then having the main …

Total answers: 1

Listening for user inputs to to manipulate functions already running

Listening for user inputs to to manipulate functions already running Question: I have 2 files, main.py and app.py main.py import _thread import time def launch(thread_name): h = Hello() h.say_hello() def input_reader(thread_name): global should_say_bye should_say_bye = False x = input() if x.lower() == "q": # Should run the say_bye() function from the Hello class. But using …

Total answers: 2

Python3 : How to spawn jobs in parallel

Python3 : How to spawn jobs in parallel Question: I am pretty new to multithreading and would like to explore. I have a json file, that provides some config. Based on this, i need to kick off some processing. Here is the config { "job1":{ "param1":"val1", "param2":"val2" }, "job2":{ "param3":"val3", "param4":"val4" } } and here …

Total answers: 2

How to do things on a certain background window with python?

How to do things on a certain background window with python? Question: I am playing a game and in order to make things easier, I have a basic python script that repeatedly presses ‘z’. import pydirectinput import time time.sleep(3) while True: pydirectinput.press(‘z’) I believe that due to directx issues, only pydirecinput library works and other …

Total answers: 1