I’m writing a program which allows me to control a vanilla Minecraft server using python. The first thing I wanted to make is a auto-restart feature. Everything works fine except that I cannot do sys.exit() or similar things, I’m not sure but I think this is because of the Timer. I tried t.cancel() but t is a local variable so
Tag: multithreading
How can I kill a thread with python
I am making a random number guessing game with GUI (Tkinter) and this comes up RuntimeError: threads can only be started once. I’m trying to kill the thread but I can’t find any way. Here’s the code: In the first function (main) is where I call the Thread and in the second function (process) is where I want to kill
Needs assistance with Async or Multithreading task
I’m new in parallel programming currently needs to run app as a background process which contains several tasks inside. Currently executing only do_something(), it blocks execution of do_something2(). Could please anyone explain me how to implement that? Should I use asyncio or something else? Thank you. Answer I think, however, you need to organize your code as follows so that
How to modify global numpy array safely with multithreading in Python?
I am trying to run my simulations in a threadpool and store my results for each repetition in a global numpy array. However, I get problems while doing that and I am observing a really interesting behavior with the following (, simplified) code (python 3.7): The issue is: I get the correct “Start record & Finish record” outputs, e.g. Start
How long does it take to create a thread in python
I’m trying to finish my programming course and I’m stuck on one exercise. I have to count how much time it takes in Python to create threads and whether it depends on the number of threads created. I wrote a simple script and I don’t know if it is good: In times[] I got a 10000 results near 0.0 or
How to let a Flask web page (route) run in the background while on another web page(route)
So i’m creating this application and a part of it is a web page where a trading algorithm is testing itself using live data. All that is working but the issue is if i leave (exit) the web page, it stops. I was wondering how i can keep it running in the background indefinitely as i want the algorithm to
python: subprocess returns nothing when running scripts which take longer time
Beginner here with subrpocess problem: The below line works fine when I run both the scripts with less data which takes around 10-20minutes, however with bigger data to be processed the subprocess returns nothing once both the scripts are completed (lets say in an hour). Also: Often with lesser data, it behaves abnormally as well i.e. not returning the status_code/going
Calculating a for loop with different indexes simultaneosuly
I have the following for function: This for loop takes a long time to calculate the values for the data frame as it has to loop 50 times for each row (it takes approximately 62 seconds) I tried to use multiprocessor pool from this question. My code looks like this now: I run the function asynchronously with different values for
Why does this program call the wrong method? [Python, MultiTimer library]
I ran into a bizarre issue while trying to structure my code as follows: At the beginning, the program starts n multi timers that repeatedly call methods m_1 to m_n every t_1 to t_n seconds. To implement this, I use the MultiTimer library (https://pypi.org/project/multitimer/). For flexibility I define a named tuple at the start of the program that contains the
How do I pass an async function to a thread target in Python?
I have the following code: and I need to give it to a Thread as a target: The error that I get is “some_callback is never awaited”. Any ideas how can I solve this problem? Answer You can do it by adding function between to execute async: