you're not making much sense... Do you want to have that processes running on another thread so you can continue doing something else? Do you just want to execute that little script then after it finishes it moves on? What are you trying to do EXACTLY?
ov3rcl0ck
I want to have that processes running on another thread and ability to continue doing something else.
and
I DONT want just to execute that little script then after it finishes it moves on.
ov3rcl0ck
I want to have that processes running on another thread and ability to continue doing something else.
and
I DONT want just to execute that little script then after it finishes it moves on.
...commands1...
...commands2...
call to t.py and imediately go on next command3
...commands3...
...commands4...
and i think separate process is the best in this time
First off Subprocess is a default module for python, next subprocess doesn't spawn a new thread, you need the multithreading module that comes default with the interpreter, also knowing object orientated programming will help. Try this little example:
#If you change the arugments of __init__ modify the bellow also
self.arg1=ARG1
self.arg2=ARG2
def run(self):
#THIS IS WERE YOUR CODE GOES!
t=THREAD(ARG1,ARG2)
t.start()
t.join()
The easiest way to do it is make a thread out of a function but this will lose alot of functionality and is a messy way of doing things IMO. Here it is:
#If you change the arugments of __init__ modify the bellow also
self.arg1=ARG1
self.arg2=ARG2
def run(self):
print"RUN"
#THIS IS WERE YOUR CODE GOES!
ARG1,ARG2=1,2
t=THREAD(ARG1,ARG2)
t.start()
t.join()
error:
Traceback (most recent call last):
File "D:\Desktop_MARI\threading\th.py", line 14, in <module>
t.start()
File "C:\Python25\lib\threading.py", line 432, in start
raise RuntimeError("thread.__init__() not called")
RuntimeError: thread.__init__() not called
#If you change the arugments of __init__ modify the bellow also
self.arg1=ARG1
self.arg2=ARG2
def run(self):
print"RUN"
#THIS IS WERE YOUR CODE GOES!
ARG1,ARG2=1,2
t=THREAD(ARG1,ARG2)
t.start()
t.join()
Forgot a line. But you do realize this is an example and i posted it so you can adjust it to your needs, if you don't understand it you're not ready for threading, so this script probably won't work, and if it does its not gonna do anything.If you don't understand it you're not ready for threading.
Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.
This thread is more than three months old
No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.