Beginner Threaded file reading access

Tim Roberts timr at probo.com
Fri Mar 26 02:24:21 EST 2004


jnoller at reference-info.com (Jesse Noller) wrote:
>
>I'm fairly new to python as a language - and really new to
>multithreaded application dev, so please be gentle.
>
>Right now, I have a script that basically looks like:
>
>def foo():
>
>   f = open(file, "r")
>   for lines in file.readlines:
>        do something
>        bar(var, var)
>        write stuff to a results file
>   file.close
>   return
>
>foo()
>
>Now, what the file I am opening contains is a whole bunch of lines
>with a filepath in it I need to process with foo() and bar() - each
>transaction writes some data to some log files.
>
>I am trying to figure out with how best to approach multithreading
>this

Multithreading will not help this sequence unless (A) you have multiple
processors, or (B) the processing in bar() needs to wait for something.  If
bar() is CPU bound, you would get the same performance by just executing
sequentially.
-- 
- Tim Roberts, timr at probo.com
  Providenza & Boekelheide, Inc.



More information about the Python-list mailing list