looking for blocking on read of a real file (not socket or pipe)

Discussion in 'Python' started by Steven, Dec 13, 2004.

  1. Steven

    Steven Guest

    Hello,
    I'm seeking a read method that will block until new data is available. Is
    there such a python function that does that?

    Thanks,

    Steven Howe
    Steven, Dec 13, 2004
    #1
    1. Advertising

  2. "Steven" <> wrote:

    > I'm seeking a read method that will block until new data is available. Is
    > there such a python function that does that?


    read until end of file, wait a while, seek to position you tried to read from
    when you reached the end, and read again. see:

    http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/157035

    (also see the comments, but ignore the last one; he is missing something)

    </F>
    Fredrik Lundh, Dec 13, 2004
    #2
    1. Advertising

  3. Steven

    Peter Hansen Guest

    Steven wrote:
    > I'm seeking a read method that will block until new data is available. Is
    > there such a python function that does that?


    It may be relevant which platform(s) are of interest. Linux?
    Mac? Windows? All? The more cross-platform this needs to
    be, the less likely it exists...
    Peter Hansen, Dec 14, 2004
    #3
  4. Steven

    Guest

    I doubt that the recipe you recomended will work at all in the case of
    different processes. To do this right file has to be open in shared
    mode (by both programs). Python does not support shared access.
    In the case of one program, but different threads probably this will
    work.
    , Dec 14, 2004
    #4
  5. <> wrote:

    > I doubt that the recipe you recomended will work at all in the case of
    > different processes. To do this right file has to be open in shared
    > mode (by both programs). Python does not support shared access.
    > In the case of one program, but different threads probably this will
    > work.


    do you always assume that everyone uses the same operating system as
    you do? (even if the user agent they used to post the message doesn't run
    on your operating system... ;-)

    </F>
    Fredrik Lundh, Dec 14, 2004
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Tim Black
    Replies:
    1
    Views:
    1,078
    Alan Kennedy
    Aug 3, 2004
  2. placid
    Replies:
    8
    Views:
    1,343
    Durumdara
    Aug 4, 2006
  3. Replies:
    3
    Views:
    202
    grocery_stocker
    Aug 31, 2007
  4. Serge Savoie
    Replies:
    4
    Views:
    255
    Serge Savoie
    Oct 1, 2008
  5. Stuart Moore

    pipe - non blocking read? (fork/Win32)

    Stuart Moore, Jul 2, 2003, in forum: Perl Misc
    Replies:
    6
    Views:
    324
    Bryan Castillo
    Jul 7, 2003
Loading...

Share This Page