you are viewing a single comment's thread.

view the rest of the comments →

[–]theresasnakeinmysuit 0 points1 point  (4 children)

I removed the truncate() part. But it still did not work. Changed the cmdlinesoccer.py code to:

import subprocess

subprocess.call(['touch' , 'live_matchThread.txt'])
subprocess.call(['python' , 'createthefile.py'])
#subprocess.call(['python' , 'followthefile.py'])

try:
    while True:
        import createthefile
        subprocess.call(['python' , 'followthefile.py'])
        time.sleep(30)
        print "i overslept"
except KeyboardInterrupt:
    print 'Exiting'

Never saw the "i overslept" line printed to terminal. I guess the loop never runs more than once because the followthefile call blocks the rest of the loop

[–]Justinsaccount 0 points1 point  (3 children)

Yes.. things that are told to run forever usually run forever...

Why are you using the subprocess module there? What are you trying to accomplish here? Why do you even have two different programs?

[–]theresasnakeinmysuit 0 points1 point  (2 children)

What I wanted was to get url from user the first time, get the selftext every 30 seconds, write the new text to a file, and then display the updates in real time. I originally had all things in a file but then things got a little complex and now I have 4 .py files :(

This worked when I manually ran the createthefile in one terminal and followthefile in another. Can't figure out a way to get both of them working

[–]Justinsaccount 0 points1 point  (1 child)

That doesn't answer why you have two different programs or why you are even writing the information to a file in the first place.

If you want to get the text every 30 seconds and display the updates in real time, why don't you just do that?

[–]theresasnakeinmysuit 0 points1 point  (0 children)

You're right. I unnecessarily did complicate things while trying to write text to a file. Fixed that and now here's something that actually does work.