1

A Python 2.7 script runs fine on Windows 7 64-bit.

  • However the exact same script myscript.pyw simply renamed to have a .pyw extension runs for some time before crashing. It is started by double clicking on the file to run it.

This script uses subprocess module to run another program, and ctypes module to check for user idle time in a infinite while loop.

while True:
    try:
        runSomeCode()
    except Exception(e)
        logging.error(e)

Strangely the crashing of the .pyw file does not cause any errors to be logged to file.

Any ideas what may have happened?

Nyxynyx
  • 61,411
  • 155
  • 482
  • 830
  • Printing to screen can take significant time, maybe a race condition changing outcome depending on that? – 101 Jun 13 '16 at 03:29
  • Try printing out sys.version, sys.path, etc within the script. The .py script might be being opened with a different version of Python to .pyw – Hugh Fisher Jun 13 '16 at 07:04
  • @101 Turns out removing all `print` statements solved the problem in my tests so far. Mind explaining the race condition? – Nyxynyx Jun 13 '16 at 21:17
  • If there's a race condition causing a crash it would completely depend on your code, but I could imagine it given you're using `subprocess` and `ctypes` (and those modules could certainly cause crashes not caught by `Exception`). Can you post `runSomeCode` or at least a minimal example? – 101 Jun 14 '16 at 01:00

0 Answers0