Timeout on read()?

David Bolen db3l at fitlinxx.com
Thu Aug 24 14:13:00 EDT 2000


"Alex Martelli" <alex at magenta.com> writes:

> You clearly have more experience with overlapped I/O on NT, than
> I have, so, thanks for sharing this experience!  What about
> asynchronously called completion routines -- how good/bad/reliable/&c
> have you found them, if you've tried them out?

I don't tend to use completion routines as much (as mentioned later in
the post) because the explicit synchronization of the overlapped I/O
has tended to fit better with my code to this point.  I actually like
threads in many cases too, so I'm not always trying to replace one
with the other.  But my take on things is that once you've got NT off
treating a bit of I/O as an asynchronous operation (whether you're
going to use the overlapped event to signal its completion or have a
completion routine) you're in good shape.  At least NT seems well
structured to manage such I/O operations - where I seem to get into
trouble is when I let it start blocking internally on I/O operations.
It's gotten so that I just default to an overlapped I/O with the
blocking GetOverlappedResult just to avoid any risk.  Of course, then
I get bit by the cases where you can't do that (like anonymous pipes,
which don't support overlapped I/O) :-)

> You sure you don't need to know when the machine is about to shut
> down, change operating parameters, etc?  If you do, the message
> loop is good to have anyway, so it's not any extra work for sockets...:-)

For operating parameters, since I'm often concerned with portability,
I'd rather not depend on such things as windows notification of
registry changes and what not, but implement my own application
notification when its configuration has changed.

For the shutdown, even without a message loop you get shutdown
"nicely" by the SCM via the standard notification mechanism - I don't
think you can really refuse it like you could with WM_ system
notification although I could probably delay it a bunch, but all I
want to do is be graceful - not interfere with the shutdown.  I'm
normally just a background daemon - oops, "service" - that nobody ever
sees but just keeps on tickin' :-)

But I'm also influenced by far more Unix background than Win32, so I
appreciate this thread - it's given me some incentive to invest some
more time into some of these issues to see how I might be better tying
into the system - it'll be less portable (another goal of most of my
code), but when in Rome...

--
-- David
-- 
/-----------------------------------------------------------------------\
 \               David Bolen            \   E-mail: db3l at fitlinxx.com  /
  |             FitLinxx, Inc.            \  Phone: (203) 708-5192    |
 /  860 Canal Street, Stamford, CT  06902   \  Fax: (203) 316-5150     \
\-----------------------------------------------------------------------/



More information about the Python-list mailing list