FAQ
I am trying to figure out the best approach to solve this problem:

I want to poll various directories(can be run in the main thread).
Once I notice a file has been added to any directory, I grab a lock,
spawn a thread to go perform the necessary actions, and then release
the lock.

--
Thanks for the help,
Minesh Patel

Search Discussions

  • Jean-Paul Calderone at Mar 6, 2009 at 11:16 pm

    On Fri, 6 Mar 2009 14:50:51 -0800, Minesh Patel wrote:
    I am trying to figure out the best approach to solve this problem:

    I want to poll various directories(can be run in the main thread).
    Once I notice a file has been added to any directory, I grab a lock,
    spawn a thread to go perform the necessary actions, and then release
    the lock.
    That's not a description of a problem. That's a description of a
    potential solution. What problem are you trying to solve?
    --
    Thanks for the help,
    Minesh Patel
    --
    http://mail.python.org/mailman/listinfo/python-list
  • Minesh Patel at Mar 6, 2009 at 11:35 pm

    On Fri, Mar 6, 2009 at 3:16 PM, Jean-Paul Calderone wrote:
    On Fri, 6 Mar 2009 14:50:51 -0800, Minesh Patel wrote:

    I am trying to figure out the best approach to solve this problem:

    I want to poll various directories(can be run in the main thread).
    Once I notice a file has been added to any directory, I grab a lock,
    spawn a thread to go perform the necessary actions, and then release
    the lock.
    That's not a description of a problem. ?That's a description of a potential
    solution. ?What problem are you trying to solve?
    I have a build system that is outputting various forms of
    installations in a particular directory structure, e.g. /pxe-installs,
    /iso-install, /dd-installs, etc...

    I need to monitor each directory for the latest install, take it and
    go perform some tests on a specific machine. I would like these
    testing tasks to run concurrently for the obvious reasons.

    Thanks again for the help,
    Minesh
  • Lie Ryan at Mar 7, 2009 at 5:01 am

    Minesh Patel wrote:
    On Fri, Mar 6, 2009 at 3:16 PM, Jean-Paul Calderone wrote:
    On Fri, 6 Mar 2009 14:50:51 -0800, Minesh Patel wrote:
    I am trying to figure out the best approach to solve this problem:

    I want to poll various directories(can be run in the main thread).
    Once I notice a file has been added to any directory, I grab a lock,
    spawn a thread to go perform the necessary actions, and then release
    the lock.
    That's not a description of a problem. That's a description of a potential
    solution. What problem are you trying to solve?
    I have a build system that is outputting various forms of
    installations in a particular directory structure, e.g. /pxe-installs,
    /iso-install, /dd-installs, etc...

    I need to monitor each directory for the latest install, take it and
    go perform some tests on a specific machine. I would like these
    testing tasks to run concurrently for the obvious reasons.
    Why not use subprocess. For each update to the directory you spawn a new
    subprocess.
  • Alex23 at Mar 7, 2009 at 6:56 am

    On Mar 7, 9:35?am, Minesh Patel wrote:
    I need to monitor each directory for the latest install, take it and
    go perform some tests on a specific machine. I would like these
    testing tasks to run concurrently for the obvious reasons.
    There are two other options to consider:
    * greenlet, which has come out of the Stackless project:
    http://codespeak.net/py/dist/greenlet.html
    * circuits, which comes with an iNotify driver:
    http://trac.softcircuit.com.au/circuits/browser/circuits/lib/drivers/inotify_driver.py

    Both of these libraries favour concurrency over threading, I believe.
  • John Nagle at Mar 7, 2009 at 7:03 pm

    Minesh Patel wrote:
    On Fri, Mar 6, 2009 at 3:16 PM, Jean-Paul Calderone wrote:
    On Fri, 6 Mar 2009 14:50:51 -0800, Minesh Patel wrote:
    I am trying to figure out the best approach to solve this problem:

    I want to poll various directories(can be run in the main thread).
    Once I notice a file has been added to any directory, I grab a lock,
    spawn a thread to go perform the necessary actions, and then release
    the lock.
    That's not a description of a problem. That's a description of a potential
    solution. What problem are you trying to solve?
    I have a build system that is outputting various forms of
    installations in a particular directory structure, e.g. /pxe-installs,
    /iso-install, /dd-installs, etc...
    If this is under Windows, there's a Windows function to monitor a
    directory for changes. This is far more efficient than polling.

    John Nagle
  • MRAB at Mar 7, 2009 at 7:08 pm

    John Nagle wrote:
    Minesh Patel wrote:
    On Fri, Mar 6, 2009 at 3:16 PM, Jean-Paul Calderone
    wrote:
    On Fri, 6 Mar 2009 14:50:51 -0800, Minesh Patel <minesh at gmail.com>
    wrote:
    I am trying to figure out the best approach to solve this problem:

    I want to poll various directories(can be run in the main thread).
    Once I notice a file has been added to any directory, I grab a lock,
    spawn a thread to go perform the necessary actions, and then release
    the lock.
    That's not a description of a problem. That's a description of a
    potential
    solution. What problem are you trying to solve?
    I have a build system that is outputting various forms of
    installations in a particular directory structure, e.g. /pxe-installs,
    /iso-install, /dd-installs, etc...
    If this is under Windows, there's a Windows function to monitor a
    directory for changes. This is far more efficient than polling.
    You should be aware, however, that this applies only to Windows folders.
    If you want to monitor, say, a shared Mac folder from a Windows PC then
    that Windows function will fail and you'll have to fall back to polling.
  • Diez B. Roggisch at Mar 7, 2009 at 7:10 pm

    John Nagle schrieb:
    Minesh Patel wrote:
    On Fri, Mar 6, 2009 at 3:16 PM, Jean-Paul Calderone
    wrote:
    On Fri, 6 Mar 2009 14:50:51 -0800, Minesh Patel <minesh at gmail.com>
    wrote:
    I am trying to figure out the best approach to solve this problem:

    I want to poll various directories(can be run in the main thread).
    Once I notice a file has been added to any directory, I grab a lock,
    spawn a thread to go perform the necessary actions, and then release
    the lock.
    That's not a description of a problem. That's a description of a
    potential
    solution. What problem are you trying to solve?
    I have a build system that is outputting various forms of
    installations in a particular directory structure, e.g. /pxe-installs,
    /iso-install, /dd-installs, etc...
    If this is under Windows, there's a Windows function to monitor a
    directory for changes. This is far more efficient than polling.
    For various *nixes there is a similar service called "FAM" available.
    There seems to be a somewhat dated python version, but as it's bundled
    with ubuntu intrepid, it should be ok.

    http://python-fam.sourceforge.net/

    Diez

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppython-list @
categoriespython
postedMar 6, '09 at 10:50p
activeMar 7, '09 at 7:10p
posts8
users7
websitepython.org

People

Translate

site design / logo © 2022 Grokbase