[Python-Dev] Waiting method for file objects

Mark Hammond MarkH@ActiveState.com
Thu, 25 Jan 2001 11:43:35 -0800

> I would appreciate it if those of you on Windows and Macintosh
> machines would test the waiting method. The test program will take
> some porting, because it needs to write to a FIFO in background.

This didn't compile under Windows.  I have a patch (against CVS) that
compiles, but doesnt appear to work (and will be forwarded to Eric under
seperate cover) [news flash :-)  Changing the open call to add "rb" as the
mode makes it work - text v binary bites again]

I didn't try any sort of fifo test.

The sockets test failed with a socket error, but would certainly have failed
had the socket connected, as my patch includes:

#ifndef S_ISSOCK
#	define S_ISSOCK(mode) (0)

I have no idea if it managed to mail the results, but I guess not, so the
output is below.  The test file (after some small mods, including the "rb"
param) is indeed 4252 bytes long.

Hope this is useful!


This program tests the `waiting' method of file objects.
Good, you're running a patched Python with `waiting' available.

First, plain files:
There are 4252 bytes waiting to be read in this file.
Please check this with your OS's directory tools.
I'll now read a random number (3091) of bytes.
The waiting method sees 1161 bytes left.
3091 + 1161 = 4252.  That's consistent.  Test passed.
Now let's see if we can detect EOF reliably.
I'll do a read()...the waiting method now returns 0
That looks like EOF.

Now sockets:
Connecting to imap.netaxs.com's IMAP server now...
Traceback (most recent call last):
  File "c:\temp\waiting_test.py", line 57, in ?
    sock.connect(("imap.netaxs.com", 143))
  File "<string>", line 1, in connect
socket.error: (10060, 'Operation timed out')