Re: basic thread question

2009-08-25 Thread Piet van Oostrum
sturlamolden sturlamol...@yahoo.no (s) wrote: s On 25 Aug, 01:26, Piet van Oostrum p...@cs.uu.nl wrote: That's because it doesn't use copy-on-write. Thereby losing most of its advantages. I don't know SUA, but I have vaguely heard about it. s SUA is a version of UNIX hidden inside Windows

Re: basic thread question

2009-08-25 Thread sturlamolden
On 25 Aug, 13:33, Piet van Oostrum p...@cs.uu.nl wrote: I have heard about that also, but is there a Python implementation that uses this? (Just curious, I am not using Windows.) On Windows we have three different versions of Python 2.6: * Python 2.6 for Win32/64 (from python.org) does not

Re: basic thread question

2009-08-24 Thread Piet van Oostrum
Dennis Lee Bieber wlfr...@ix.netcom.com (DLB) wrote: DLB On Sun, 23 Aug 2009 22:14:17 -0700, John Nagle na...@animats.com DLB declaimed the following in gmane.comp.python.general: Multiple Python processes can run concurrently, but each process has a copy of the entire Python system, so the

Re: basic thread question

2009-08-24 Thread Dave Angel
Dennis Lee Bieber wrote: On Sun, 23 Aug 2009 22:14:17 -0700, John Nagle na...@animats.com declaimed the following in gmane.comp.python.general: Multiple Python processes can run concurrently, but each process has a copy of the entire Python system, so the memory and cache footprints

Re: basic thread question

2009-08-24 Thread Piet van Oostrum
Dave Angel da...@ieee.org (DA) wrote: DA Dennis Lee Bieber wrote: On Sun, 23 Aug 2009 22:14:17 -0700, John Nagle na...@animats.com declaimed the following in gmane.comp.python.general: Multiple Python processes can run concurrently, but each process has a copy of the entire Python

Re: basic thread question

2009-08-24 Thread sturlamolden
On 18 Aug, 22:10, Derek Martin c...@pizzashack.org wrote: I have some simple threaded code...  If I run this with an arg of 1 (start one thread), it pegs one cpu, as I would expect.  If I run it with an arg of 2 (start 2 threads), it uses both CPUs, but utilization of both is less than 50%.  

Re: basic thread question

2009-08-24 Thread sturlamolden
On 24 Aug, 13:21, Piet van Oostrum p...@cs.uu.nl wrote: But os.fork() is not available on Windows. And I guess refcounts et al. will soon destroy the sharing. Well, there is os.fork in Cygwin and SUA (SUA is the Unix subsytem in Windows Vista Professional). Cygwin's fork is a bit sluggish.

Re: basic thread question

2009-08-24 Thread Piet van Oostrum
sturlamolden sturlamol...@yahoo.no (s) wrote: s On 24 Aug, 13:21, Piet van Oostrum p...@cs.uu.nl wrote: But os.fork() is not available on Windows. And I guess refcounts et al. will soon destroy the sharing. s Well, there is os.fork in Cygwin and SUA (SUA is the Unix subsytem in s Windows

Re: basic thread question

2009-08-24 Thread sturlamolden
On 25 Aug, 01:26, Piet van Oostrum p...@cs.uu.nl wrote: That's because it doesn't use copy-on-write. Thereby losing most of its advantages. I don't know SUA, but I have vaguely heard about it. SUA is a version of UNIX hidden inside Windows Vista and Windows 7 (except in Home and Home Premium),

Re: basic thread question

2009-08-23 Thread John Nagle
Jan Kaliszewski wrote: 18-08-2009 o 22:10:15 Derek Martin c...@pizzashack.org wrote: I have some simple threaded code... If I run this with an arg of 1 (start one thread), it pegs one cpu, as I would expect. If I run it with an arg of 2 (start 2 threads), it uses both CPUs, but utilization

Re: basic thread question

2009-08-19 Thread Sean DiZazzo
On Aug 18, 4:58 pm, birdsong david.birds...@gmail.com wrote: On Aug 18, 3:18 pm, Derek Martin c...@pizzashack.org wrote: On Tue, Aug 18, 2009 at 03:10:15PM -0500, Derek Martin wrote: I have some simple threaded code...  If I run this with an arg of 1 (start one thread), it pegs one

Re: basic thread question

2009-08-18 Thread birdsong
On Aug 18, 1:10 pm, Derek Martin c...@pizzashack.org wrote: I have some simple threaded code...  If I run this with an arg of 1 (start one thread), it pegs one cpu, as I would expect.  If I run it with an arg of 2 (start 2 threads), it uses both CPUs, but utilization of both is less than 50%.  

Re: basic thread question

2009-08-18 Thread birdsong
On Aug 18, 3:18 pm, Derek Martin c...@pizzashack.org wrote: On Tue, Aug 18, 2009 at 03:10:15PM -0500, Derek Martin wrote: I have some simple threaded code...  If I run this with an arg of 1 (start one thread), it pegs one cpu, as I would expect.  If I run it with an arg of 2 (start 2

Re: thread. question

2009-02-13 Thread Tim Wintle
On Mon, 2009-02-09 at 21:02 +0100, Christian Heimes wrote: The module was renamed to _thread to stop people from using it directly. The extension module is the interface to some low level types and functions. Especially the usage of thread.start_new_thread is problematic, since it bypasses

Re: thread. question

2009-02-13 Thread Carl Banks
On Feb 9, 7:34 am, Tim Wintle tim.win...@teamrubber.com wrote: Thanks for both replies, On Mon, 2009-02-09 at 15:59 +0100, Christian Heimes wrote: You shouldn't use the thread module directly. It's not meant to be used by a user. Please stick to the threading module. You won't notice a

thread. question

2009-02-09 Thread Tim Wintle
Hi, This is my first post here - google hasn't helped much but sorry if this has been asked before. I've been wondering about some of the technicalities of locks in python (2.4 and 2.5 mainly). I'm using the old thread module as (1) I prefer the methods and (2) It should be a tiny bit faster.

Re: thread. question

2009-02-09 Thread bieffe62
On Feb 9, 2:47 pm, Tim Wintle tim.win...@teamrubber.com wrote: Hi, This is my first post here - google hasn't helped much but sorry if this has been asked before. I've been wondering about some of the technicalities of locks in python (2.4 and 2.5 mainly). I'm using the old thread module

Re: thread. question

2009-02-09 Thread Christian Heimes
Tim Wintle schrieb: Hi, This is my first post here - google hasn't helped much but sorry if this has been asked before. I've been wondering about some of the technicalities of locks in python (2.4 and 2.5 mainly). I'm using the old thread module as (1) I prefer the methods and (2) It

Re: thread. question

2009-02-09 Thread Tim Wintle
Thanks for both replies, On Mon, 2009-02-09 at 15:59 +0100, Christian Heimes wrote: You shouldn't use the thread module directly. It's not meant to be used by a user. Please stick to the threading module. You won't notice a slowdown, trust me :) I'm aware that thread is being renamed to

Re: thread. question

2009-02-09 Thread Jean-Paul Calderone
On Mon, 09 Feb 2009 15:34:02 +, Tim Wintle tim.win...@teamrubber.com wrote: Thanks for both replies, On Mon, 2009-02-09 at 15:59 +0100, Christian Heimes wrote: You shouldn't use the thread module directly. It's not meant to be used by a user. Please stick to the threading module. You

Re: thread. question

2009-02-09 Thread Christian Heimes
Tim Wintle schrieb: Thanks for both replies, On Mon, 2009-02-09 at 15:59 +0100, Christian Heimes wrote: You shouldn't use the thread module directly. It's not meant to be used by a user. Please stick to the threading module. You won't notice a slowdown, trust me :) I'm aware that thread is

Re: wxpython thread question

2008-02-11 Thread Mike Driscoll
On Feb 10, 10:26 pm, [EMAIL PROTECTED] wrote: I am new to threading and python. Currently I am working on a GUI app that will be a frontend to CLI client. I want to invoke a method of the class from GUI and run it in the thread. That works well, the problems is I dont know how can I stop

wxpython thread question

2008-02-10 Thread marcinguy
I am new to threading and python. Currently I am working on a GUI app that will be a frontend to CLI client. I want to invoke a method of the class from GUI and run it in the thread. That works well, the problems is I dont know how can I stop this operation, thread if the user would like to

Re: Thread Question

2006-08-06 Thread Gerhard Fiedler
On 2006-08-04 04:22:59, Ritesh Raj Sarraf wrote: Gerhard Fiedler wrote: Rather than downloading and zipping in the same thread, you could run multiple threads like you're doing that only download files, and one zip-it-all-up thread. After downloading a file, the download threads place a

Re: Thread Question

2006-08-05 Thread Bryan Olson
Carl Banks wrote: Ritesh Raj Sarraf wrote: Carl Banks wrote: Then change the zipping part of download_from_web to acquire and release this lock; do zipfile operations only between them. ziplock.acquire() try: do_all_zipfile_stuff_here() finally: ziplock.release() I hope while

Re: Thread Question

2006-08-05 Thread Ritesh Raj Sarraf
Bryan Olson on Saturday 05 Aug 2006 13:31 wrote: Exactly.  Only one thread can hold a lock at a time. In the code above, a form called a critical section, we might think of a thread as holding the lock when it is between the acquire() and release(). But that's not really how Python's locks

Re: Thread Question

2006-08-05 Thread Bryan Olson
Ritesh Raj Sarraf wrote: [...] I noticed that even though while one thread acquires the lock, the other threads don't respect the lock. In fact they just go ahead and execute the statements within the lock acquire statement. With this behavior, I'm ending up having a partially corrupted zip

Re: Thread Question

2006-08-05 Thread Ritesh Raj Sarraf
Bryan Olson on Saturday 05 Aug 2006 23:56 wrote: You don't want ziplock = threading.Lock() in the body of the function. It creates a new and different lock on every execution. Your threads are all acquiring different locks. To coordinate your threads, they need to be using the same lock.

Re: Thread Question

2006-08-05 Thread Simon Forman
Ritesh Raj Sarraf wrote: Bryan Olson on Saturday 05 Aug 2006 23:56 wrote: You don't want ziplock = threading.Lock() in the body of the function. It creates a new and different lock on every execution. Your threads are all acquiring different locks. To coordinate your threads, they need

Re: Thread Question

2006-08-04 Thread Ritesh Raj Sarraf
Gerhard Fiedler wrote: Rather than downloading and zipping in the same thread, you could run multiple threads like you're doing that only download files, and one zip-it-all-up thread. After downloading a file, the download threads place a message in a queue that indicates the file they have

Re: Thread Question

2006-08-04 Thread Ritesh Raj Sarraf
Carl Banks wrote: If you have multiple threads trying to access the same ZIP file at the same time, whether or not they use the same ZipFile object, you'll have trouble. You'd have to change download_from_web to protect against simultaneous use. A simple lock should suffice. Create the

Re: Thread Question

2006-08-03 Thread Ritesh Raj Sarraf
Simon Forman wrote: One other question I had, If my user passes the --zip option, download_from_web() internally (when the download is successful) zips the downloaded data to a zip file. Since in case of threading there'll be multiple threads, and say if one of the thread completes 2

Re: Thread Question

2006-08-03 Thread Ritesh Raj Sarraf
Simon Forman wrote: The other threads will just take the next request from the Queue and process it. They won't care what the one thread is doing, downloading, zipping, whatever. As I mentioned in my previous post, the other threads will also have to go through the same zip the file if the

Re: Thread Question

2006-08-03 Thread Carl Banks
Ritesh Raj Sarraf wrote: Simon Forman wrote: One other question I had, If my user passes the --zip option, download_from_web() internally (when the download is successful) zips the downloaded data to a zip file. Since in case of threading there'll be multiple threads, and say

Re: Thread Question

2006-08-03 Thread Gerhard Fiedler
On 2006-08-03 08:49:45, Ritesh Raj Sarraf wrote: I implemented it but am seeing some issues. If I use a single thread, all files are zipped to the archive. Obviously this has to work. If threads are 2 or 3 or 4 in numbers, some of the files don't show up in the archive. What would a

Re: Thread Question

2006-08-02 Thread Ritesh Raj Sarraf
Hi, I have this following situation: #INFO: Thread Support # Will require more design thoughts from Queue import Queue from threading import Thread, currentThread NUMTHREADS = variables.options.num_of_threads def run(request,

Re: Thread Question

2006-08-02 Thread Simon Forman
Ritesh Raj Sarraf wrote: Hi, I have this following situation: #INFO: Thread Support # Will require more design thoughts from Queue import Queue from threading import Thread, currentThread NUMTHREADS = variables.options.num_of_threads def

Re: Thread Question

2006-07-28 Thread Ritesh Raj Sarraf
Duncan Booth on Thursday 27 Jul 2006 17:17 wrote: What you want is to use a pool of threads so that you can configure how many requests are issued at a time (you don't want to try to issue 100 requests all in parallel). You can communicate with the threads through a Queue. Thanks to both

Re: Thread Question

2006-07-28 Thread Ritesh Raj Sarraf
And people, Is there any documentation on Python Threads or Threads in general. It'd be of great help to really understand. Ritesh Ritesh Raj Sarraf on Thursday 27 Jul 2006 16:37 wrote: Is this the correct way of threading applications ? This is the first time I'd be doing threading. So was

Re: Thread Question

2006-07-28 Thread Ritesh Raj Sarraf
Simon Forman on Thursday 27 Jul 2006 22:47 wrote: def run(request, response, func=dummy_func): ''' Get items from the request Queue, process them with func(), put the results along with the Thread's name into the response Queue. Stop running once an item is None. ''' name =

Re: Thread Question

2006-07-28 Thread Justin Azoff
Ritesh Raj Sarraf wrote: I'd like to put my understanding over here and would be happy if people can correct me at places. ok :-) So here it goes: Firstly the code initializes the number of threads. Then it moves on to initializing requestQueue() and responseQueue(). Then it moves on to

Thread Question

2006-07-27 Thread Ritesh Raj Sarraf
Hi, I have some basic doubts about thread. I have a list which has items in it which need to be downloaded from the internet. Let's say list is: list_items[] which has 100 items in it. I have a function download_from_web() which does the work of downloading the items from the web. It does

Re: Thread Question

2006-07-27 Thread Duncan Booth
Ritesh Raj Sarraf wrote: I'm planning to implement threads in my application so that multiple items can be downloaded concurrently. I want the thread option to be user-defined. Looking at the documentation of threads (Core Python Programming), I've noticed that all threads are executed a

Re: Thread Question

2006-07-27 Thread Ritesh Raj Sarraf
Duncan, I couldn't make out much from the code. Instead this is what I did. threads = [] nloops = range(len(lRawData)) for i in nloops: (sUrl, sFile, download_size, checksum) = stripper(lRawData[i]) t = threading.Thread(target=download_from_web,

Re: Thread Question

2006-07-27 Thread Simon Forman
Ritesh Raj Sarraf wrote: Duncan, I couldn't make out much from the code. Please, try again to understand Duncan's code. It's much better than what you did. Instead this is what I did. threads = [] nloops = range(len(lRawData)) for i in nloops: (sUrl, sFile,

Re: Thread Question

2006-07-27 Thread Duncan Booth
Ritesh Raj Sarraf wrote: Duncan, I couldn't make out much from the code. Instead this is what I did. threads = [] nloops = range(len(lRawData)) for i in nloops: (sUrl, sFile, download_size, checksum) = stripper(lRawData[i]) t =

Re: Thread Question

2006-07-27 Thread Duncan Booth
Simon Forman wrote: If you need help understanding it please ask questions. I, for one, would be happy to comment it for you to explain how it works. It's so nice and elegant that I've already cut-and-pasted it into my own notebook of cool useful python patterns to use in the future.

Re: Thread Question

2006-07-27 Thread Justin Azoff
Ritesh Raj Sarraf wrote: [snip] for item in list_items: download_from_web(item) This way, one items is downloaded at a time. I'm planning to implement threads in my application so that multiple items can be downloaded concurrently. I want the thread option to be user-defined. [snip]

Re: Thread Question

2006-07-27 Thread Simon Forman
Duncan Booth wrote: Simon Forman wrote: If you need help understanding it please ask questions. I, for one, would be happy to comment it for you to explain how it works. It's so nice and elegant that I've already cut-and-pasted it into my own notebook of cool useful python patterns to

Re: Thread Question

2006-03-01 Thread Aahz
In article [EMAIL PROTECTED], Kent Johnson [EMAIL PROTECTED] wrote: D wrote: My question is, how would I go about creating the thread? I have seen examples that used classes, and other examples that just called one thread start command - when should you use one over another? For simple use

Re: Thread Question

2006-03-01 Thread Just
In article [EMAIL PROTECTED], [EMAIL PROTECTED] (Aahz) wrote: In article [EMAIL PROTECTED], Kent Johnson [EMAIL PROTECTED] wrote: D wrote: My question is, how would I go about creating the thread? I have seen examples that used classes, and other examples that just called one thread

Re: Thread Question

2006-03-01 Thread Jarek Zgoda
Just napisał(a): I always felt that subclassing Thread is very unpythonic. It seems like an unfortunate leftover Javaism (much of threading.py was inspired by Java, but I don't need to tell you that). If I need some state, I create my own class, with a reference to the Thread object if

Thread Question

2006-02-28 Thread D
I have a client application that I want (behind the scenes) to check and make sure a remote host is up (i.e. by ping or TCP connect). I'm assuming that, since I want this to go on unknowingly to the user, that I would put this in a thread. My question is, how would I go about creating the

Re: Thread Question

2006-02-28 Thread Grant Edwards
On 2006-02-28, D [EMAIL PROTECTED] wrote: I have a client application that I want (behind the scenes) to check and make sure a remote host is up (i.e. by ping or TCP connect). I'm assuming that, since I want this to go on unknowingly to the user, that I would put this in a thread. Probably.

Re: Thread Question

2006-02-28 Thread Felipe Almeida Lessa
Em Ter, 2006-02-28 às 20:24 +, Grant Edwards escreveu: I have seen examples that used classes, and other examples that just called one thread start command - when should you use one over another? I'm not sure what you mean by use classes vs. calling a thread start command. My

Re: Thread Question

2006-02-28 Thread D
Thanks, Grant. I apologize for not being clear on what I meant by using classes. This is an example of what I was referring to: http://www.wellho.net/solutions/python-python-threads-a-first-example.html See the second (threaded) example. Doug --

Re: Thread Question

2006-02-28 Thread Grant Edwards
On 2006-02-28, D [EMAIL PROTECTED] wrote: Thanks, Grant. I apologize for not being clear on what I meant by using classes. This is an example of what I was referring to: http://www.wellho.net/solutions/python-python-threads-a-first-example.html Ah, I see. I had forgotten that people

Re: Thread Question

2006-02-28 Thread Felipe Almeida Lessa
Em Ter, 2006-02-28 às 20:38 +, Grant Edwards escreveu: On 2006-02-28, D [EMAIL PROTECTED] wrote: Thanks, Grant. I apologize for not being clear on what I meant by using classes. This is an example of what I was referring to:

Re: Thread Question

2006-02-28 Thread Grant Edwards
On 2006-02-28, Felipe Almeida Lessa [EMAIL PROTECTED] wrote: # He meant calling direct vs. subclassing. In your example you called the Thread class directly, but you could have subclassed it. Yup. I should have realized that. # In your case, Edwards, I'd prefer subclassing because then

Re: Thread Question

2006-02-28 Thread Kent Johnson
D wrote: My question is, how would I go about creating the thread? I have seen examples that used classes, and other examples that just called one thread start command - when should you use one over another? For simple use it doesn't matter. Use a class when you want to add more state or

Re: Thread Question

2006-02-28 Thread D
Guys - I appreciate the clarification. So it looks like they used a class for the ping thread because they were a) running multiple instances of the thread concurrently and b) needing to keep track of the state of each instance, correct? I believe that in my case, since I will be just running