This is the mail archive of the cygwin mailing list for the Cygwin project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Python hang

I'm having a problem with blocking I/O in python.

It is reproduced by the program below. When I run it on cygwin, it prints "About to read fifo..." then "About to write regular file..." then hangs. Ctrl-C and Ctrl-Z don't kill it - I've had to kill it with Task Manager.

For comparison, I've run it on a couple of Ubuntu boxes, and it prints "About to read fifo..." then "About to write regular file..." then "Finished writing regular file." then it exits normally.

If anyone can shed some light on why this is happening, I'd appreciate it.

Output of "cygcheck -s -v -r" is attached.

#!/usr/bin/env python

import sys, os, tempfile, threading, time

tmpdir = tempfile.mkdtemp()

def write_regular_file():
  print 'About to write regular file...'
    filename = os.path.join(tmpdir, 'regular-file')
    with open(filename, 'w') as fout:
      fout.write('file contents')
    print 'Finished writing regular file.'

def create_and_read_fifo_in_separate_thread():
  fifo_filename = os.path.join(tmpdir, 'fifo')
  def run():
    print 'About to read fifo...'
    with open(fifo_filename) as fin:
    # This will never print, even if the test is successful:
    print 'Finished reading fifo.'
  thread = threading.Thread(target=run)
  thread.daemon = True

if __name__ == '__main__':


Attachment: cygcheck.out
Description: Text document

Problem reports:
Unsubscribe info:

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]