Skip to content Skip to sidebar Skip to footer

Leave Some Code Running While Executing More

I am starting a loop in python, and after I start the loop I want the execution of code after the loop to carry on, while the loop keeps looping (in the 'background'). x=True whil

Solution 1:

From what I understand, what you want is to create a Thread that keeps executing some tasks in the background.

http://docs.python.org/library/threading.html

Threading is a moderately complex issue, so giving you a recipe here wouldn't amount to much. I suggest you take a look at the documentation to understand what's involved.

Update your question or create a new one if you then have troubles with something specific to the implementation.

EDIT: I agree with the comment made by Tim Hoffman, the correct solution depends on what you're trying to achieve. From my understanding, threading should work for you, but if you give us more details, it might be easier to give a more precise answer.

Solution 2:

Following OP's wish I'm posting the answer. :) There are multiple libraries for achieving what you are trying to do. Most known include:

There are subtle differences between them, but I guess that you shouldn't worry about it at the moment. I encourage you though to read more about mutli-processing and threading in general. Also "green" threads is an interesting alternative.

Post a Comment for "Leave Some Code Running While Executing More"