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
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
> 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
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
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
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
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,
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:
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():
>>
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
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
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
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
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
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
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
First, thanks Joseph for taking the time to reply.
My comments interspersed below:
On Fri, Jan 2, 2015 at 2:39 PM, Joseph Lee
wrote:
> Hi,
> Answers are below.
>
> -Original Message-
> From: Tutor [mailto:tutor-bounces+joseph.lee22590=gmail@python.org] On
> Behalf Of Rance Hall
> Se
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 "while
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
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
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
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
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 (
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
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
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
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
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
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
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
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
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
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
"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
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
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
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
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
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
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
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
"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
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
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
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
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
Hi Tony,
Thank you very much for your pointer. I think I understand what are you
explaining to me. Do you mind give me some code examples? I am still trying
to grasp the gui programming overall. And it is really over my head. I
really appreciate your help. Thank you
-Ben
On 3/23/07, Tony Cappel
"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
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 <[
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
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
> 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
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
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
Ø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
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.
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
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
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
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
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
>> 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
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
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
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
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
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)
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
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
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
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
[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 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
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
> 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
Ok, comments inside your code ...
nephish a écrit :
> Pierre Barbier de Reuille wrote:
>
>> nephish a écrit :
>>
>>
>>> Pierre Barbier de Reuille wrote:
>>>
>>> [...]
>>> ok, i am still having a little problem understanding.
>>> tried it but i don't know if i have things set in the right order.
Pierre Barbier de Reuille wrote:
>nephish a écrit :
>
>
>>Pierre Barbier de Reuille wrote:
>>
>>[...]
>>ok, i am still having a little problem understanding.
>>tried it but i don't know if i have things set in the right order.
>>
>>
>>gtk.gdk.threads_init()
>># Here initialize what you want
>>[.
nephish a écrit :
> Pierre Barbier de Reuille wrote:
>
> [...]
> ok, i am still having a little problem understanding.
> tried it but i don't know if i have things set in the right order.
>
>
> gtk.gdk.threads_init()
> # Here initialize what you want
> [...]
> # Launch the Gtk loop
> gtk.gdk.t
Pierre Barbier de Reuille wrote:
>nephish a écrit :
>
>
>>Hello there !
>>
>>
>
>Hello,
>
>
>
>>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
nephish a écrit :
> Hello there !
Hello,
> 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.
Please, do not mix "process" and "threads"
80 matches
Mail list logo