Re: [Tutor] threading for each line in a large file, and doing it right

2018-04-25 Thread Alan Gauld via Tutor
On 25/04/18 09:27, Alan Gauld via Tutor wrote: >> for i in $(< massive_input.file); do >> time_intensive_stuff_in_bash i & disown >> : >> done > > Its the same except in bash you start a whole > new process so instead of using threading you > use concurrent. concurrent -> multiprocessin

Re: [Tutor] threading for each line in a large file, and doing it right

2018-04-25 Thread Alan Gauld via Tutor
On 25/04/18 03:26, Evuraan wrote: > Please consider this situation : > Each line in "massive_input.txt" need to be churned by the > "time_intensive_stuff" function, so I am trying to background it. What kind of "churning" is involved? If its compute intensive threading may not be the right answer

Re: [Tutor] threading for each line in a large file, and doing it right

2018-04-24 Thread Danny Yoo
> Please consider this situation : > Each line in "massive_input.txt" need to be churned by the > "time_intensive_stuff" function, so I am trying to background it. > > import threading > > def time_intensive_stuff(arg): ># some code, some_conditional >return (some_conditional) > > with open

[Tutor] threading for each line in a large file, and doing it right

2018-04-24 Thread Evuraan
Greetings! Please consider this situation : Each line in "massive_input.txt" need to be churned by the "time_intensive_stuff" function, so I am trying to background it. import threading def time_intensive_stuff(arg): # some code, some_conditional return (some_conditional) with open("massi

Re: [Tutor] threading tutorial

2017-06-02 Thread Michael C
ihave to look at this tomorrow, thanks for the reply! On Thu, Jun 1, 2017 at 6:18 PM Alan Gauld via Tutor wrote: > On 01/06/17 16:30, Michael C wrote: > > Oh i get it alright, however in my code I have to push the W button like > > this: > > > > import pyautogui > > import time > > > > pyautog

Re: [Tutor] threading tutorial

2017-06-01 Thread Alan Gauld via Tutor
On 01/06/17 16:30, Michael C wrote: > Oh i get it alright, however in my code I have to push the W button like > this: > > import pyautogui > import time > > pyautogui.keyDown('w') > time.sleep(2) > pyautogui.keyUp('w') So this emulates a user pressing the w key for 2 seconds. What's not clear i

Re: [Tutor] threading tutorial

2017-06-01 Thread Michael C
let me try that! thanks! On Thu, Jun 1, 2017 at 10:52 AM, Jerry Hill wrote: > On Thu, Jun 1, 2017 at 11:30 AM, Michael C > wrote: > > Oh i get it alright, however in my code I have to push the W button like > > this: > > > > import pyautogui > > import time > > > > pyautogui.keyDown('w') > > t

Re: [Tutor] threading tutorial

2017-06-01 Thread Jerry Hill
On Thu, Jun 1, 2017 at 11:30 AM, Michael C wrote: > Oh i get it alright, however in my code I have to push the W button like > this: > > import pyautogui > import time > > pyautogui.keyDown('w') > time.sleep(2) > pyautogui.keyUp('w') ... > theoretically deals with my problem, in practice though,

Re: [Tutor] threading tutorial

2017-06-01 Thread Michael C
Oh i get it alright, however in my code I have to push the W button like this: import pyautogui import time pyautogui.keyDown('w') time.sleep(2) pyautogui.keyUp('w') while the example you gave: def fn(): global run_me while run_me: ... do some work ... and then elsewhere you go:

Re: [Tutor] threading tutorial

2017-05-26 Thread Michael C
message received, i ll take a look tomorrow asap. thanks for replying!!! On Thu, May 25, 2017 at 3:03 PM, Cameron Simpson wrote: > On 25May2017 11:52, Michael C wrote: > >> Right now all i need is to grab 3 values from 3 variables before killing a >> thread, like this: >> >> def stuff(): >>

Re: [Tutor] threading tutorial

2017-05-25 Thread Cameron Simpson
On 25May2017 11:52, Michael C wrote: Right now all i need is to grab 3 values from 3 variables before killing a thread, like this: def stuff(): do stuff, get values, (x,y,d) # main code startthread(stuff(), blah) # if else need to sleep or kill the thread, and because I'll restart the thr

Re: [Tutor] threading tutorial

2017-05-25 Thread Michael C
Right now all i need is to grab 3 values from 3 variables before killing a thread, like this: def stuff(): do stuff, get values, (x,y,d) # main code startthread(stuff(), blah) # if else need to sleep or kill the thread, and because I'll restart the thread later, I'd like to get the values

[Tutor] threading tutorial

2017-05-25 Thread Michael C
Hi all: I tried to google for tutorials of threading, but they are all equally confusing. Does someone know of a good page or a book that talk about threading? thanks! ___ Tutor maillist - Tutor@python.org To unsubscribe or change subsc

Re: [Tutor] threading in python 2.7 - 2nd version

2015-01-05 Thread Rance Hall
Cameron: This was the exact issue, and I had initially suspected as much, but had no idea how to fix it. I had tried to use the global variable directive, but as it turned out I had misused it. Anyway, everything is working as it should. Thanks Rance On Mon, Jan 5, 2015 at 12:39 AM, Cameron S

Re: [Tutor] threading in python 2.7 - 2nd version

2015-01-05 Thread Joseph Lee
Hi, My answers are below. -Original Message- From: Tutor [mailto:tutor-bounces+joseph.lee22590=gmail@python.org] On Behalf Of Rance Hall Sent: Sunday, January 4, 2015 9:20 PM To: tutor Subject: [Tutor] threading in python 2.7 - 2nd version Thanks to the advice from Joseph and Alan, I

Re: [Tutor] threading in python 2.7 - 2nd version

2015-01-04 Thread Cameron Simpson
On 04Jan2015 23:19, Rance Hall wrote: Thanks to the advice from Joseph and Alan, I hacked a quick python script which demonstrates my problem more accurately. Its not board specific as was my last code. This sample works the same on my pcduino as it does on my desktop. [...] [...] exitFlag = 0

[Tutor] threading in python 2.7 - 2nd version

2015-01-04 Thread Rance Hall
Thanks to the advice from Joseph and Alan, I hacked a quick python script which demonstrates my problem more accurately. Its not board specific as was my last code. This sample works the same on my pcduino as it does on my desktop. #threading problem example import threading import sys impor

Re: [Tutor] threading in python2.7

2015-01-03 Thread Steven D'Aprano
On Fri, Jan 02, 2015 at 12:39:36PM -0800, Joseph Lee wrote: > Threads introduce interesting issues. For instance, due to Python's global > interpreter lock (GIL), only one thread can run at a given time. I'd like to make a technical correction here. The GIL is not a *language* requirement, it is

Re: [Tutor] threading in python2.7

2015-01-02 Thread Rance Hall
On Fri, Jan 2, 2015 at 3:18 PM, Alan Gauld wrote: > On 02/01/15 20:17, Rance Hall wrote: > >> I bought myself a pcduino 3 nano development board for Christmas and >> started picking up python again after a long forced hiatus. The board >> runs >> Ubuntu Precise >> > > Snap!(ish), I got an arduin

Re: [Tutor] threading in python2.7

2015-01-02 Thread Rance Hall
half Of Rance Hall > Sent: Friday, January 2, 2015 12:17 PM > To: tutor > Subject: [Tutor] threading in python2.7 > > Each of the lights and sound functions are placed in a "while not > exitFlag:" > loop > > I think I'm running into some variable scoping issues

Re: [Tutor] threading in python2.7

2015-01-02 Thread Joseph Lee
Hi, Answers are below. -Original Message- From: Tutor [mailto:tutor-bounces+joseph.lee22590=gmail@python.org] On Behalf Of Rance Hall Sent: Friday, January 2, 2015 12:17 PM To: tutor Subject: [Tutor] threading in python2.7 Each of the lights and sound functions are placed in a "

Re: [Tutor] threading in python2.7

2015-01-02 Thread Alan Gauld
On 02/01/15 20:17, Rance Hall wrote: I bought myself a pcduino 3 nano development board for Christmas and started picking up python again after a long forced hiatus. The board runs Ubuntu Precise Snap!(ish), I got an arduino Uno and RaspberryPi. As I understand it the pcDuino is just a PC and

[Tutor] threading in python2.7

2015-01-02 Thread Rance Hall
I bought myself a pcduino 3 nano development board for Christmas and started picking up python again after a long forced hiatus. The board runs Ubuntu Precise Working with development boards has me navigating the inner working of python threading and I find myself at a loss. My current project i

Re: [Tutor] threading mind set

2012-05-13 Thread Russel Winder
On Mon, 2012-05-14 at 10:31 +1000, Steven D'Aprano wrote: [...] > No hard compared to what? Compared to sequential programming. [...] > My argument is that once you move beyond the one-operation-after-another > programming model, almost any parallel processing problem is harder than the > equiv

Re: [Tutor] threading mind set

2012-05-13 Thread Devin Jeanpierre
On Sun, May 13, 2012 at 8:31 PM, Steven D'Aprano wrote: >> Using processes and message passing, using dataflow, actors or CSP, >> parallelism and concurrency is far more straightforward. Not easy, >> agreed, but then programming isn't easy. > > My argument is that once you move beyond the one-oper

Re: [Tutor] threading mind set

2012-05-13 Thread Steven D'Aprano
Russel Winder wrote: Steven, On Sun, 2012-05-13 at 10:22 +1000, Steven D'Aprano wrote: carlo locci wrote: Hello All, I've started to study python a couple of month ago(and I truly love it :)), however I'm having some problems understanding how to modify a sequential script and make it multithr

Re: [Tutor] threading mind set

2012-05-13 Thread Russel Winder
Steven, On Sun, 2012-05-13 at 10:22 +1000, Steven D'Aprano wrote: > carlo locci wrote: > > Hello All, > > I've started to study python a couple of month ago(and I truly love it :)), > > however I'm having some problems understanding how to modify a sequential > > script and make it multithreaded (

Re: [Tutor] threading mind set

2012-05-13 Thread Steven D'Aprano
bob gailer wrote: On 5/12/2012 8:22 PM, Steven D'Aprano wrote: By the way, in future, please don't decorate your code with stars: I think you got stars because the code was posted in HTML and bolded. Plain text readers add the * to show emphasis. I think you have it the other way around: if y

Re: [Tutor] threading mind set

2012-05-12 Thread bob gailer
def read(): couple of observations 1 - it is customary to put all import statements at the beginning of the file. 2 - it is customary to begin variable and function names with a lower case letter. 3 - it is better to avoid using built-in function names common method names (e.g. read). def rea

Re: [Tutor] threading mind set

2012-05-12 Thread bob gailer
On 5/12/2012 8:22 PM, Steven D'Aprano wrote: By the way, in future, please don't decorate your code with stars: I think you got stars because the code was posted in HTML and bolded. Plain text readers add the * to show emphasis. When i copied and pasted the code it came out fine. carlo: in fu

Re: [Tutor] threading mind set

2012-05-12 Thread Steven D'Aprano
carlo locci wrote: Hello All, I've started to study python a couple of month ago(and I truly love it :)), however I'm having some problems understanding how to modify a sequential script and make it multithreaded (I think it's because I'm not used to think in that way), No, that's because mult

[Tutor] threading mind set

2012-05-12 Thread carlo locci
Hello All, I've started to study python a couple of month ago(and I truly love it :)), however I'm having some problems understanding how to modify a sequential script and make it multithreaded (I think it's because I'm not used to think in that way), as well as when it's best to use it(some say th

Re: [Tutor] Threading and Sockets

2010-11-15 Thread Wayne Werner
Well, I solved the issue myself I changed the server class to the following: class Server(threading.Thread): def __init__(self, port=1500, max_connections=5): ''' Setup the server elements. ''' threading.Thread.__init__(self) self.server = socket.socket(socket.AF_INET

[Tutor] Threading and Sockets

2010-11-15 Thread Wayne Werner
Hi, I'm working on creating a server/client bit of software using threading and sockets (it's a project so I can't use something like twisted), and I've run into a slight issue with my server. My server currently looks like this: class ClientThread(threading.Thread): def __init__(self, socket

Re: [Tutor] Threading...

2009-04-27 Thread Kent Johnson
On Mon, Apr 27, 2009 at 9:29 AM, A.T.Hofkamp wrote: > Kent Johnson wrote: >> >> On Mon, Apr 27, 2009 at 2:46 AM, A.T.Hofkamp wrote: >>> >>> you are making >>> a IO-bound app, so threading doesn't buy you anything in performance and >>> gives a big headache in data protection Perhaps I misinterpr

Re: [Tutor] Threading...

2009-04-27 Thread A.T.Hofkamp
Kent Johnson wrote: On Mon, Apr 27, 2009 at 2:46 AM, A.T.Hofkamp wrote: you are making a IO-bound app, so threading doesn't buy you anything in performance and gives a big headache in data protection Please explain. Presumably the single-threaded app is not IO-bound. Adding threads can push i

Re: [Tutor] Threading...

2009-04-27 Thread Kent Johnson
On Mon, Apr 27, 2009 at 2:46 AM, A.T.Hofkamp wrote: > you are making > a IO-bound app, so threading doesn't buy you anything in performance and > gives a big headache in data protection Please explain. Presumably the single-threaded app is not IO-bound. Adding threads can push it to the point of

Re: [Tutor] Threading...

2009-04-26 Thread A.T.Hofkamp
Spencer Parker wrote: Would the best route for this be threading? or is there another way to go about it? At #python, you'd quickly get redirected away from threading (you are making a IO-bound app, so threading doesn't buy you anything in performance and gives a big headache in data protecti

Re: [Tutor] Threading...

2009-04-25 Thread Kent Johnson
On Fri, Apr 24, 2009 at 5:26 PM, Spencer Parker wrote: > I have a script that I want to test MySQL sonnections with.  The way I have > the script working is to just create connections, but I realized that it is > going to wait for the first one to stop before starting a new connection.  I > want t

Re: [Tutor] Threading...

2009-04-24 Thread Alan Gauld
"Spencer Parker" wrote in message news:c7a040fa0904241426h70a0c82bhf95e476fe5ed0...@mail.gmail.com... I have a script that I want to test MySQL sonnections with. The way I have the script working is to just create connections, but I realized that it is going to wait for the first one to stop b

[Tutor] Threading...

2009-04-24 Thread Spencer Parker
I have a script that I want to test MySQL sonnections with. The way I have the script working is to just create connections, but I realized that it is going to wait for the first one to stop before starting a new connection. I want to throw a ton of open connections at it to see what the connecti

Re: [Tutor] threading not working how about fork?

2008-10-22 Thread Kent Johnson
On Wed, Oct 22, 2008 at 5:44 PM, Ertl, John C CIV 63134 <[EMAIL PROTECTED]> wrote: > Classification: UNCLASSIFIED > Caveat (s): FOUO ?? > Thanks for the help and I am looking into the pyprocessing but threading is > causing too many headaches (I may have to rewrite things). Lets say I have > som

[Tutor] threading not working how about fork?

2008-10-22 Thread Ertl, John C CIV 63134
Classification: UNCLASSIFIED Caveat (s): FOUO Thanks for the help and I am looking into the pyprocessing but threading is causing too many headaches (I may have to rewrite things). Lets say I have something as simple as below: def takeTime(a): print "Started %s" % a time.sleep(10)

Re: [Tutor] Threading

2008-09-11 Thread Dick Moores
At 05:31 PM 9/11/2008, Kent Johnson wrote: On Thu, Sep 11, 2008 at 10:56 AM, Oleg Oltar <[EMAIL PROTECTED]> wrote: > Hi! > > I need to open about 1200 urls from my database. And to check that those > urls are really exists. > > I used urllib2.urlopen for it. But it's a little bit slow. I thought

Re: [Tutor] Threading

2008-09-11 Thread Dick Moores
At 05:31 PM 9/11/2008, Kent Johnson wrote: On Thu, Sep 11, 2008 at 10:56 AM, Oleg Oltar <[EMAIL PROTECTED]> wrote: > Hi! > > I need to open about 1200 urls from my database. And to check that those > urls are really exists. > > I used urllib2.urlopen for it. But it's a little bit slow. I thought

Re: [Tutor] Threading

2008-09-11 Thread Kent Johnson
On Thu, Sep 11, 2008 at 10:56 AM, Oleg Oltar <[EMAIL PROTECTED]> wrote: > Hi! > > I need to open about 1200 urls from my database. And to check that those > urls are really exists. > > I used urllib2.urlopen for it. But it's a little bit slow. I thought that > it's might be a good idea to do it in

Re: [Tutor] Threading

2008-09-11 Thread Jeff Younker
On Sep 11, 2008, at 7:56 AM, Oleg Oltar wrote: Hi! I need to open about 1200 urls from my database. And to check that those urls are really exists. I used urllib2.urlopen for it. But it's a little bit slow. I thought that it's might be a good idea to do it in a threads. So it can add so

[Tutor] Threading

2008-09-11 Thread Oleg Oltar
Hi! I need to open about 1200 urls from my database. And to check that those urls are really exists. I used urllib2.urlopen for it. But it's a little bit slow. I thought that it's might be a good idea to do it in a threads. So it can add some performance to my code. Unfortunately I can't get sta

Re: [Tutor] threading: getting latest elements from list/dict

2008-05-05 Thread bob gailer
Vaibhav.bhawsar wrote: Hello I have a thread updating a dictionary with new elements. How can I check for new elements as they are inserted into the dictionary by the thread? In general is it safe to read a dictionary or a list while it is being updated by a running thread? Does the dictionary

[Tutor] threading: getting latest elements from list/dict

2008-05-05 Thread Vaibhav.bhawsar
Hello I have a thread updating a dictionary with new elements. How can I check for new elements as they are inserted into the dictionary by the thread? In general is it safe to read a dictionary or a list while it is being updated by a running thread? Does the dictionary or list have to be locked w

[Tutor] threading: getting latest elements from list/dict

2008-05-05 Thread Vaibhav.bhawsar
Hello I have a thread updating a dictionary with new elements. How can I check for new elements as they are inserted into the dictionary by the thread? In general is it safe to read a dictionary or a list while it is being updated by a running thread? Does the dictionary or list have to be locked w

Re: [Tutor] Threading in Python

2007-09-20 Thread Kent Johnson
Eric Brunson wrote: > I mention that because when you combine a fork with an exec, you get a > spawn. Your parent process duplicates itself, but the child process > chooses to exec another process. So the child copy of the initial > process is replaced by new running binary and you have a spaw

Re: [Tutor] Threading in Python

2007-09-20 Thread Alan Gauld
"James" <[EMAIL PROTECTED]> wrote > I have a question regarding threading in Python. I'm trying to > write > a wrapper script in Python that will spin off multiple (lots!) of > instances of an I/O benchmark/testing utility. Are these instances of an external program or simply instances of some

Re: [Tutor] Threading in Python

2007-09-19 Thread Michael Langford
Python has no way to force the OS to schedule a process on a given processor (therefore you're safe). If you use multiple processes, you can get true concurrency. This is one of the reasons process based concurrency is superior to threads (*ducks from items thrown by threadophiles*). Then again, y

Re: [Tutor] Threading in Python

2007-09-19 Thread Eric Brunson
James wrote: > Thanks for the quick reply. > > Interesting. I'm a little overwhelmed with the different terminology > (fork, spawn, thread, etc.). I'm under the impression that I'm > supposed to use os.fork() or os.spawn() for something like what I'm > trying to do (start multiple instances

Re: [Tutor] Threading in Python

2007-09-19 Thread James
Thanks for the quick reply. Interesting. I'm a little overwhelmed with the different terminology (fork, spawn, thread, etc.). I'm under the impression that I'm supposed to use os.fork() or os.spawn() for something like what I'm trying to do (start multiple instances of the I/O utility from

Re: [Tutor] Threading in Python

2007-09-19 Thread Kent Johnson
James wrote: > Hi. :) > > I have a question regarding threading in Python. I'm trying to write > a wrapper script in Python that will spin off multiple (lots!) of > instances of an I/O benchmark/testing utility. I'm very interested > in doing this in Python, but am unsure if this is a goo

[Tutor] Threading in Python

2007-09-19 Thread James
Hi. :) I have a question regarding threading in Python. I'm trying to write a wrapper script in Python that will spin off multiple (lots!) of instances of an I/O benchmark/testing utility. I'm very interested in doing this in Python, but am unsure if this is a good idea. I thought I re

Re: [Tutor] threading and gui programming

2007-03-23 Thread Ben
t make sense? You may not always need threading in a gui app. It just depends on what you ar edoing, and how long it takes. Message: 1 Date: Tue, 20 Mar 2007 14:49:50 -0400 From: Ben <[EMAIL PROTECTED]> Subject: [Tutor] threading and gui programming To: tutor@python.org Message-ID:

Re: [Tutor] threading and gui programming

2007-03-21 Thread Alan Gauld
"Ben" <[EMAIL PROTECTED]> wrote > What really confuses > me is that there are so many gui programming options for python > (i.e. > pywin32, wxPython, etc). Is this means that all of these available > gui > options be able to integrate with threading? Thanks. Yes, they all have the concept of a

Re: [Tutor] threading and gui programming

2007-03-20 Thread Ben
That makes sense. I am a newbie to python programming. What really confuses me is that there are so many gui programming options for python (i.e. pywin32, wxPython, etc). Is this means that all of these available gui options be able to integrate with threading? Thanks. On 3/20/07, Kent Johnson <[

Re: [Tutor] threading and gui programming

2007-03-20 Thread Kent Johnson
Ben wrote: > Hi all, > > I am curious about one thing. I have been doing research on gui > programming. One thing that I don't understand is why there are some > examples uses threading in the gui examples. Is there any benefits or > advantages for using the threading in the gui programming? Th

[Tutor] threading and gui programming

2007-03-20 Thread Ben
Hi all, I am curious about one thing. I have been doing research on gui programming. One thing that I don't understand is why there are some examples uses threading in the gui examples. Is there any benefits or advantages for using the threading in the gui programming? Thanks. ___

Re: [Tutor] threading

2006-08-16 Thread Terry Carroll
On Tue, 15 Aug 2006, Jeff Peery wrote: > hello, how do I stop a thread? In all the threaded apps I have so far, I've worked with Queues to give them work. So my technique has been to put a special-purpose element on the Queue, which is recognized by the thread, which exits. I usually have mu

Re: [Tutor] threading

2006-08-15 Thread Danny Yoo
> It kinda depends what your thread is doing, and what technique you are > using to keep it alive, but one possibility is to do something like: > > class Worker(threading.Thread): >def run(self): >self.running = True >while(self.running): ># do stuff > >def st

Re: [Tutor] threading

2006-08-15 Thread Jeff Peery
h, ok, well that is what I am currently doing but something is causing it to continue... guess I have some digging around to do. thanks for the help!JeffJohn Fouhy <[EMAIL PROTECTED]> wrote: On 16/08/06, Jeff Peery <[EMAIL PROTECTED]> wrote:> hello, how do I stop a thread? do I need to kill it

Re: [Tutor] threading

2006-08-15 Thread John Fouhy
On 16/08/06, Jeff Peery <[EMAIL PROTECTED]> wrote: > hello, how do I stop a thread? do I need to kill it or can I simply call a > stop function... kinda like the start function? I read a bit on google and > it sounded like using a kill isn't recommended for some reason... so how is > this thing sto

[Tutor] threading

2006-08-15 Thread Jeff Peery
hello, how do I stop a thread? do I need to kill it or can I simply call a stop function... kinda like the start function? I read a bit on google and it sounded like using a kill isn't recommended for some reason... so how is this thing stopped? thanks!Jeff Yahoo! Messenger with Voice. Make PC-t

[Tutor] Threading synchronization (was: Unit testing

2006-06-29 Thread Terry Carroll
On Thu, 29 Jun 2006, Tino Dai wrote: > Between the producer and consumer threads, does the consumer end of the > queue sit there and wait for something to come down the queue... Yes. The following call: workunit = self.inQ.get(True) means, try to take something off the queue, and if the que

Re: [Tutor] Threading

2006-06-28 Thread Kent Johnson
Øyvind wrote: > And, does anyone know of some great sites where I can learn more about > threads? I have found a lot, but they are not basic enough. I have no idea > what a 'lock' is, as most all sites assumes one should. So, the simpler > the better... "The Little Book of Semaphores" is a good in

[Tutor] Threading

2006-06-28 Thread Øyvind
Hello. I am trying to learn threading, and found a good example at: http://effbot.org/librarybook/queue.htm (Using the Queue module with a maximum size). It works like a dream as is. But, I added it to a downloading-script I have made before. The difference is that in my version it has a wxPython

Re: [Tutor] Threading + socket server (blocking IO)

2006-02-19 Thread Liam Clarke
Hi, Just poking at threads, I'm contemplating doing something that I think may be a very dumb thing to do, or it may work fine. In the following code - import threading import Queue import reg import msvcrt class ParseThread(threading.Thread): def __init__(self, Q, parser): self.

Re: [Tutor] Threading + socket server (blocking IO)

2006-02-18 Thread Liam Clarke
Thanks Kent, I'll try swapping it around and see how it goes. As for the setDaemon, my apologies. There's a while True: if msvcrt.kbhit(): break loop afterwards, so at a keypress it exits, hence the daemon stuff. On 2/19/06, Kent Johnson <[EMAIL PROTECTED]> wrote: > Liam Clarke wro

Re: [Tutor] Threading + socket server (blocking IO)

2006-02-18 Thread Kent Johnson
Liam Clarke wrote: > Hi, > > Just coming back to the server end of things. Kent, could I please ask > you to confirm that I'm not doing anything abnormal with the > ThreadingMixIn? The code is here at rafb: > http://www.rafb.net/paste/results/915JVm90.html > > Basically, when I test it using a sc

Re: [Tutor] Threading + socket server (blocking IO)

2006-02-17 Thread Liam Clarke
Hi, Just coming back to the server end of things. Kent, could I please ask you to confirm that I'm not doing anything abnormal with the ThreadingMixIn? The code is here at rafb: http://www.rafb.net/paste/results/915JVm90.html Basically, when I test it using a script to generate the datagrams via

Re: [Tutor] Threading + socket server (blocking IO)

2006-02-07 Thread Kent Johnson
Liam Clarke wrote: > On 2/7/06, Kent Johnson <[EMAIL PROTECTED]> wrote: > >>Liam Clarke wrote: >> >>>Hi all, >>> >>>About to embark on my first foray into threading, and rather unsure of >>>initial approach. I have a basic UDPServer from SocketServer running >>>using serve_forever(). I'd like to s

Re: [Tutor] Threading + socket server (blocking IO)

2006-02-06 Thread Liam Clarke
On 2/7/06, Kent Johnson <[EMAIL PROTECTED]> wrote: > Liam Clarke wrote: > > Hi all, > > > > About to embark on my first foray into threading, and rather unsure of > > initial approach. I have a basic UDPServer from SocketServer running > > using serve_forever(). I'd like to stick this in a thread w

Re: [Tutor] Threading + socket server (blocking IO)

2006-02-06 Thread Matthew Webber
>> The GIL prevents Python from effectively running multiple threads on multiple processors. This statement is slightly misleading. You can run multiple threads on a multi-processor system quite effectively, the limitation of the GIL is simply that you can typically utilize only one processor at

Re: [Tutor] Threading + socket server (blocking IO)

2006-02-06 Thread Kent Johnson
Matthew Webber wrote: >>>The GIL prevents Python from effectively running multiple threads on > > multiple processors. > > This statement is slightly misleading. You can run multiple threads on a > multi-processor system quite effectively, the limitation of the GIL is > simply that you can typic

Re: [Tutor] Threading + socket server (blocking IO)

2006-02-06 Thread Kent Johnson
Liam Clarke wrote: > Is this going to be possible? I've been reading about GIL and what not > in the Tutor archives and this presentation here - > http://starship.python.net/crew/aahz/OSCON2001/ but I'm a little > unsure as to what is possible. Python has good support for multiple threads running

Re: [Tutor] Threading + socket server (blocking IO)

2006-02-06 Thread Kent Johnson
Liam Clarke wrote: > Hi all, > > About to embark on my first foray into threading, and rather unsure of > initial approach. I have a basic UDPServer from SocketServer running > using serve_forever(). I'd like to stick this in a thread where it can > endlessly loop waiting for incoming packets, and

[Tutor] Threading + socket server (blocking IO)

2006-02-06 Thread Liam Clarke
Hi all, About to embark on my first foray into threading, and rather unsure of initial approach. I have a basic UDPServer from SocketServer running using serve_forever(). I'd like to stick this in a thread where it can endlessly loop waiting for incoming packets, and pushing the received data into

Re: [Tutor] threading issues

2005-10-26 Thread Kent Johnson
Chris Hallman wrote: > I was finally able to get my script to not show duplicate PINGs. I also > realized that my script was not PINGing all the hosts in the input file. Congratulations on getting it to work! See below for a few notes. > Here is my latest version: > > > import os, re, string

Re: [Tutor] threading issues

2005-10-25 Thread Chris Hallman
You're right. I'm inexperienced with classes and threading. The example you gave (www.wellho.net) was the same example I used as the basis for my script however I wasn't able to get it to work. I couldn't figure out what the -q parameter is (it's not a valid parameter on the *nix I have access to)

Re: [Tutor] threading issues

2005-10-23 Thread Kent Johnson
Chris Hallman wrote: > > I made a mistake in my first email. I meant that I can't get fc to > write to the file. Here is the error: > > Traceback (most recent call last): > File "thread_test_ping.py", line 37, in ? > output.write(fc + " failures found.\n") > TypeError: unsupported oper

Re: [Tutor] threading issues

2005-10-23 Thread Danny Yoo
On Sun, 23 Oct 2005, Chris Hallman wrote: > I made a mistake in my first email. I meant that I can't get fc to write > to the file. Here is the error: > > Traceback (most recent call last): > File "thread_test_ping.py", line 37, in ? > output.write(fc + " failures found.\n") > TypeError: uns

Re: [Tutor] threading issues

2005-10-23 Thread Chris Hallman
I made a mistake in my first email. I meant that I can't get fc to write to the file. Here is the error: Traceback (most recent call last):   File "thread_test_ping.py", line 37, in ?     output.write(fc + " failures found.\n") TypeError: unsupported operand type(s) for +: 'int' and 'str' I

Re: [Tutor] threading issues

2005-10-22 Thread Kent Johnson
Chris Hallman wrote: > > I hacked together my first script to learn threading. I'm seeing some > weird output. > > This script will PING approximately 1,000 routers. I added a few print > commands for debugging so I can see if it runs faster than a single > threaded script. It blazes through t

[Tutor] threading issues

2005-10-22 Thread Chris Hallman
I hacked together my first script to learn threading. I'm seeing some weird output. This script will PING approximately 1,000 routers. I added a few print commands for debugging so I can see if it runs faster than a single threaded script. It blazes through the routers, however I'm seeing multip

Re: [Tutor] Threading in a for loop

2005-09-23 Thread Bill Burns
[Kent Johnson] Here are some more resources for you. This cookbook recipe is very similar to what you want to do, just customize workerThread1 to do the actual work. It shows how to use a Queue to communicate back to the GUI thread. http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/82965

Re: [Tutor] Threading in a for loop

2005-09-22 Thread Kent Johnson
Here are some more resources for you. This cookbook recipe is very similar to what you want to do, just customize workerThread1 to do the actual work. It shows how to use a Queue to communicate back to the GUI thread. http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/82965 Here are a coup

Re: [Tutor] Threading in a for loop

2005-09-22 Thread Kent Johnson
Bill Burns wrote: > I've got a few questions regarding Threading. I've never used threads > before and I want to make sure I'm doing it correctly ;-) > > I have a GUI app and it processes Tiff files to PDF (or PostScript). The > GUI has a ListBox which the user populates with files to convert. You

[Tutor] Threading in a for loop

2005-09-20 Thread Bill Burns
I've got a few questions regarding Threading. I've never used threads before and I want to make sure I'm doing it correctly ;-) I have a GUI app and it processes Tiff files to PDF (or PostScript). The GUI has a ListBox which the user populates with files to convert. You click on a Button and the f

Re: [Tutor] threading problem in GUI

2005-09-16 Thread Jacob S.
> Hello there ! > i am having a problem with threading. > OK, i have this GUI app that i am building with pygtk. > there is a process (four actually, just working on getting one right now) > that needs to run in the background. > there is a button that starts the background function. But, it locks

Re: [Tutor] [tutor] threading problem in GUI

2005-09-08 Thread nephish
Pierre Barbier de Reuille wrote: >Great :) > >Just to be clear about that: you can see the "connect" line as a dynamic >registration process (with the symetric disconnect operation available >via ... "disconnect"). The only thing you need is to connect (at >runtime) the even before it's called (ob

Re: [Tutor] [tutor] threading problem in GUI

2005-09-08 Thread Pierre Barbier de Reuille
Great :) Just to be clear about that: you can see the "connect" line as a dynamic registration process (with the symetric disconnect operation available via ... "disconnect"). The only thing you need is to connect (at runtime) the even before it's called (obvious isn't it ? ;) ), but you have no o

Re: [Tutor] [tutor] threading problem in GUI

2005-09-07 Thread nephish
Pierre Barbier de Reuille wrote: >nephish a écrit : > > >>one more thing. >>if i uncomment the lines >>gtk.threads_enter() >>and >>gtk.threads_leave() >>the whole thing locks up when the function is called. >>the gui, and the thread both lock up. >> >> > >Well, that's just normal. However, w

Re: [Tutor] [tutor] threading problem in GUI

2005-09-07 Thread nephish
Pierre Barbier de Reuille wrote: >nephish a écrit : > > >>one more thing. >>if i uncomment the lines >>gtk.threads_enter() >>and >>gtk.threads_leave() >>the whole thing locks up when the function is called. >>the gui, and the thread both lock up. >> >> > >Well, that's just normal. However, w

Re: [Tutor] [tutor] threading problem in GUI

2005-09-07 Thread Pierre Barbier de Reuille
nephish a écrit : > > one more thing. > if i uncomment the lines > gtk.threads_enter() > and > gtk.threads_leave() > the whole thing locks up when the function is called. > the gui, and the thread both lock up. Well, that's just normal. However, what you should do is to send a signal from your th

Re: [Tutor] [tutor] threading problem in GUI

2005-09-07 Thread nephish
nephish wrote: > Serial1() just call the function ... it will be evaluated and then the > result will be sent to Thread.start ... > > So try: > > Thread.start(Serial) > > >ok, >so far the thread runs fine in the background, but just does not send the >output to the >textb

  1   2   >