0

Eclipse seems to terminate long running scripts automatically. I have this simple script written in Python and it runs fine on IDLE, however when I run it in eclipse the program terminates without printing any output values in the console. Is there something that I could modify in the settings to control this?

def main():
    max = 8000
    for i in getPrimes():
        if(i <= max):
            print(i, end=" ")
        else:
            return


def getPrimes():
    testNum = 2
    isPrime = True
    while True:
        for i in range(2, testNum):
            if testNum % i == 0:
                isPrime = False
                continue

        if isPrime:
            yield testNum
        else:
            isPrime = True

        testNum += 1


if __name__ == "__main__": main()
Jonah Graham
  • 7,890
  • 23
  • 55
  • I assume from the context you are using PyDev? If so, tagging it as such will increase relevant readership. Either way, if you could confirm which method you are using to run it would help. Also, how long until it terminates, a few seconds, a few hours, etc. – Jonah Graham Feb 20 '16 at 11:27
  • Indeed, I am using PyDev. And the script only runs for about three seconds and terminates. – Ahmed Yousry Feb 20 '16 at 11:45
  • It also might be interesting for you to take a look at fast prime sieve algorithms: https://pypi.python.org/pypi/pyprimesieve, http://stackoverflow.com/questions/2068372/fastest-way-to-list-all-primes-below-n – MaxU - stand with Ukraine Feb 20 '16 at 12:04

1 Answers1

1

This is a new one on me, but you have hit a long standing bug in Eclipse I never knew about: Bug 23406

It turns out that on Windows some very long lines are not displayed properly even though the text is there.

As a workaround, try changing your print line from print(i, end=" ") to print(i) and you should see your output.

Jonah Graham
  • 7,890
  • 23
  • 55