Event::wait with timeout gives delay

2014-02-09 Thread Okko Willeboordse
vent::wait (same for Queue::wait) causes a delay. This is perhaps caused by a polling loop inside the wait implementation. This polling loop sleeps some time depending on the timeout. Probably wait timeout > 1ms => sleep = 1ms A wait with timeout can take at least this sleep time even though

Condition.wait() behavior with timeout

2012-01-30 Thread Ross Boylan
The Python 2.7 documents for the threading module says, in part, wait([timeout])¶ Wait until notified or until a timeout occurs. If the calling thread has not acquired the lock when this method is called, a RuntimeError is raised. This method releas

Re: copytree with timeout in windows

2009-07-07 Thread Tim Golden
Astan Chee wrote: Tim Golden wrote: Astan Chee wrote: Hi, I'm trying to modify the copytree function in shutil so that any file being copied does not take more than 5 minutes (if it does, skip to the next one). One suggestion is to use the CopyFileEx API exposed in the win32file modu

Re: copytree with timeout in windows

2009-07-06 Thread Astan Chee
Tim Golden wrote: Astan Chee wrote: Hi, I'm trying to modify the copytree function in shutil so that any file being copied does not take more than 5 minutes (if it does, skip to the next one). One suggestion is to use the CopyFileEx API exposed in the win32file module from pywin32.

Re: copytree with timeout in windows

2009-07-06 Thread Tim Golden
Astan Chee wrote: Hi, I'm trying to modify the copytree function in shutil so that any file being copied does not take more than 5 minutes (if it does, skip to the next one). One suggestion is to use the CopyFileEx API exposed in the win32file module from pywin32. That allows for a callback

copytree with timeout in windows

2009-07-06 Thread Astan Chee
Hi, I'm trying to modify the copytree function in shutil so that any file being copied does not take more than 5 minutes (if it does, skip to the next one). This is what I have so far: import shutil import signal, os def handler(signum, frame): print 'Signal handler called with signal', si

httplib.HTTPSConnection with timeout support (pyton 2.5.1)

2007-11-05 Thread mmomar
Hi, I am using a HTTPS connection to invoke a cgi-script. I want to use a timeout between the sending the request and receiving the response, so what I want to do is when the request is send, the client should wait for a specified time, drop the connection and then do some thing else. I found ou

Re: with timeout(...):

2007-03-31 Thread Nick Craig-Wood
John Nagle <[EMAIL PROTECTED]> wrote: > Diez B. Roggisch wrote: > > Nick Craig-Wood wrote: > > > > > >>Did anyone write a contextmanager implementing a timeout for > >>python2.5? > >> > >>And have it work reliably and in a cross platform way! > > > > Cross platform isn't the issue here - reliab

Re: with timeout(...):

2007-03-31 Thread Nick Craig-Wood
Hendrik van Rooyen <[EMAIL PROTECTED]> wrote: > "Nick Craig-Wood" <[EMAIL PROTECTED]> wrote: > > > I'd like there to be something which works well enough for day to day > > use. Ie doesn't ever wreck the internals of python. It could have > > some caveats like "may not timeout during C functio

Re: with timeout(...):

2007-03-30 Thread Diez B. Roggisch
Nick Craig-Wood schrieb: > Diez B. Roggisch <[EMAIL PROTECTED]> wrote: >>> I beleive the convention is when calling an OS function which might >>> block the global interpreter lock is dropped, thus allowing other >>> python bytecode to run. >> >> So what? That doesn't help you, as you are single-t

Re: with timeout(...):

2007-03-30 Thread Hendrik van Rooyen
"Nick Craig-Wood" <[EMAIL PROTECTED]> wrote: > I'd like there to be something which works well enough for day to day > use. Ie doesn't ever wreck the internals of python. It could have > some caveats like "may not timeout during C functions which haven't > released the GIL" and that would still

Re: with timeout(...):

2007-03-29 Thread John Nagle
Diez B. Roggisch wrote: > Nick Craig-Wood wrote: > > >>Did anyone write a contextmanager implementing a timeout for >>python2.5? >> >>And have it work reliably and in a cross platform way! > > Cross platform isn't the issue here - reliability though is. To put it > simple: can't be done that way

Re: with timeout(...):

2007-03-29 Thread Jean-Paul Calderone
On Thu, 29 Mar 2007 11:30:04 -0500, Nick Craig-Wood <[EMAIL PROTECTED]> wrote: >Diez B. Roggisch <[EMAIL PROTECTED]> wrote: >> > >> > I beleive the convention is when calling an OS function which might >> > block the global interpreter lock is dropped, thus allowing other >> > python bytecode to ru

Re: with timeout(...):

2007-03-29 Thread Nick Craig-Wood
Diez B. Roggisch <[EMAIL PROTECTED]> wrote: > > > > I beleive the convention is when calling an OS function which might > > block the global interpreter lock is dropped, thus allowing other > > python bytecode to run. > > > So what? That doesn't help you, as you are single-threaded here. The >

Re: with timeout(...):

2007-03-29 Thread Nick Craig-Wood
Hendrik van Rooyen <[EMAIL PROTECTED]> wrote: > "Nick Craig-Wood" <[EMAIL PROTECTED]> wrote: > > > Well, yes there are different levels of potential reliability with > > different implementation strategies for each! > > Gadzooks! Foiled again by the horses for courses argument. > > ; - ) ;

Re: with timeout(...):

2007-03-29 Thread Diez B. Roggisch
> > I beleive the convention is when calling an OS function which might > block the global interpreter lock is dropped, thus allowing other > python bytecode to run. So what? That doesn't help you, as you are single-threaded here. The released lock won't prevent the called C-code from taking as

Re: with timeout(...):

2007-03-29 Thread Hendrik van Rooyen
"Nick Craig-Wood" <[EMAIL PROTECTED]> wrote: > Well, yes there are different levels of potential reliability with > different implementation strategies for each! Gadzooks! Foiled again by the horses for courses argument. ; - ) - Hendrik -- http://mail.python.org/mailman/listinfo/python-list

Re: with timeout(...):

2007-03-28 Thread Nick Craig-Wood
Hendrik van Rooyen <[EMAIL PROTECTED]> wrote: > "Nick Craig-Wood" <[EMAIL PROTECTED]> wrote: > > Hendrik van Rooyen <[EMAIL PROTECTED]> wrote: > > > But would be useful to be able to do without messing with > > > threads and GUI and imports. > > > Could be hard to implement as the interpreter

Re: with timeout(...):

2007-03-27 Thread Hendrik van Rooyen
"Nick Craig-Wood" <[EMAIL PROTECTED]> wrote: > Hendrik van Rooyen <[EMAIL PROTECTED]> wrote: > > > But would be useful to be able to do without messing with > > threads and GUI and imports. > > Could be hard to implement as the interpreter would have > > to be assured of getting control

Re: with timeout(...):

2007-03-27 Thread Klaas
On Mar 27, 3:28 pm, Paul Rubin wrote: > Nick Craig-Wood <[EMAIL PROTECTED]> writes: > > It could be made to work I'm sure by getting the interpreter to check > > for timeouts every few hundred bytecodes (like it does for thread > > switching). > > Is there some reason not

Re: with timeout(...):

2007-03-27 Thread Paul Rubin
Nick Craig-Wood <[EMAIL PROTECTED]> writes: > It could be made to work I'm sure by getting the interpreter to check > for timeouts every few hundred bytecodes (like it does for thread > switching). Is there some reason not to use sigalarm for this? -- http://mail.python.org/mailman/listinfo/pytho

Re: with timeout(...):

2007-03-27 Thread Nick Craig-Wood
Hendrik van Rooyen <[EMAIL PROTECTED]> wrote: > so Diez is probably right that the way to go is to put the timer in the > python interpreter loop, as its the only thing around that you could > more or less trust to run all the time. > > But then it will not read as nice as Nick's wish, but mo

Re: with timeout(...):

2007-03-27 Thread Nick Craig-Wood
Klaas <[EMAIL PROTECTED]> wrote: > On Mar 26, 3:30 am, Nick Craig-Wood <[EMAIL PROTECTED]> wrote: > > Did anyone write a contextmanager implementing a timeout for > > python2.5? > > > > I'd love to be able to write something li

Re: with timeout(...):

2007-03-26 Thread Hendrik van Rooyen
"Diez B. Roggisch" <[EMAIL PROTECTED]> wrote: > Nick Craig-Wood wrote: > > > Did anyone write a contextmanager implementing a timeout for > > python2.5? > > > > I'd love to be able to write something like > > > > wit

Re: with timeout(...):

2007-03-26 Thread Nick Craig-Wood
James Stroud <[EMAIL PROTECTED]> wrote: > Nick Craig-Wood wrote: > > Did anyone write a contextmanager implementing a timeout for > > python2.5? > > > > I'd love to be able to write something like > > > > with timeout(5.0) as exceeded

Re: with timeout(...):

2007-03-26 Thread Nick Craig-Wood
[EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > On Mar 26, 3:16 pm, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote: > > But to make that work reliably, it has to be ensured that no sideeffects > > occur while being in some_long_running_stuff. which doesn't only extend to > > python itself, but also e

Re: with timeout(...):

2007-03-26 Thread Klaas
On Mar 26, 3:30 am, Nick Craig-Wood <[EMAIL PROTECTED]> wrote: > Did anyone write a contextmanager implementing a timeout for > python2.5? > > I'd love to be able to write something like > > with timeout(5.0) as exceeded: > some_long_running_stuff() &g

Re: with timeout(...):

2007-03-26 Thread irstas
On Mar 26, 3:16 pm, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote: > But to make that work reliably, it has to be ensured that no sideeffects > occur while being in some_long_running_stuff. which doesn't only extend to > python itself, but also external modules and systems (file writing, network > c

Re: with timeout(...):

2007-03-26 Thread Diez B. Roggisch
Nick Craig-Wood wrote: > Did anyone write a contextmanager implementing a timeout for > python2.5? > > I'd love to be able to write something like > > with timeout(5.0) as exceeded: > some_long_running_stuff() > if exceeded: > print "

Re: with timeout(...):

2007-03-26 Thread James Stroud
Nick Craig-Wood wrote: > Did anyone write a contextmanager implementing a timeout for > python2.5? > > I'd love to be able to write something like > > with timeout(5.0) as exceeded: > some_long_running_stuff() > if exceeded: > print "

with timeout(...):

2007-03-26 Thread Nick Craig-Wood
Did anyone write a contextmanager implementing a timeout for python2.5? I'd love to be able to write something like with timeout(5.0) as exceeded: some_long_running_stuff() if exceeded: print "Oops - took too long!" And have it work reliably and in a cro

Re: send with timeout socket

2006-09-22 Thread Bryan Olson
Stéphane Ninin wrote: > I want to make sure that, if nothing is sent after some time, > if event "terminated" is set, > then the thread doesnot spend more time trying to send something which > has become useless. You should be good then. The timeout is on each send(), and send times out if and o

Re: send with timeout socket

2006-09-22 Thread Bryan Olson
Stéphane Ninin wrote: > Yes, I typed it *really* too fast, it would be more something like this: > > def sendall(self, data): > while data: > try: > n = self.request.send(data) > data = data[n:] > except socket.timeout, e: >

Re: send with timeout socket

2006-09-22 Thread Bryan Olson
Stéphane Ninin wrote: > I have a few questions regarding sockets with timeouts. > > Assuming you set a timeout t on a socket s and then call: > > > 1) s.sendall > Is the socket.timeout exception thrown when > not the data was sent in the given time t > or if nothing was sent ? Neither; not exa

Re: send with timeout socket

2006-09-22 Thread Steve Holden
Stéphane Ninin wrote: > Hello, > > I have a few questions regarding sockets with timeouts. > > Assuming you set a timeout t on a socket s and then call: > > > 1) s.sendall > Is the socket.timeout exception thrown when > not the data was sent in the given time t > or if nothing was sent ? >

Re: Run process with timeout

2005-10-17 Thread Donn Cave
In article <[EMAIL PROTECTED]>, [EMAIL PROTECTED] (Alex Martelli) wrote: > Micah Elliott <[EMAIL PROTECTED]> wrote: [... re problem killing children of shell script ...] > > Is there any way to enable Python's subprocess module to do (implicit?) > > group setup to ease killing of all children?

Re: Run process with timeout

2005-10-17 Thread Alex Martelli
Micah Elliott <[EMAIL PROTECTED]> wrote: > Is there any way to enable Python's subprocess module to do (implicit?) > group setup to ease killing of all children? If not, is it a reasonable > RFE? Not as far as I know. It might be a reasonable request in suitable dialects of Unix-like OSes, thou

Re: Run process with timeout

2005-10-17 Thread Micah Elliott
On Oct 17, Alex Martelli wrote: > Natan <[EMAIL PROTECTED]> wrote: > > I have a python script under linux where I poll many hundreds of > > interfaces with mrtg every 5 minutes. Today I create some threads and > > use os.system(command) to run the process, but some of them just hang. > > I would li

Re: Run process with timeout

2005-10-17 Thread P
Natan wrote: > Hi. > > I have a python script under linux where I poll many hundreds of > interfaces with mrtg every 5 minutes. Today I create some threads and > use os.system(command) to run the process, but some of them just hang. > I would like to terminate the process after 15 seconds if it do

Re: Run process with timeout

2005-10-17 Thread Alex Martelli
Natan <[EMAIL PROTECTED]> wrote: > Hi. > > I have a python script under linux where I poll many hundreds of > interfaces with mrtg every 5 minutes. Today I create some threads and > use os.system(command) to run the process, but some of them just hang. > I would like to terminate the process afte

Run process with timeout

2005-10-17 Thread Natan
Hi. I have a python script under linux where I poll many hundreds of interfaces with mrtg every 5 minutes. Today I create some threads and use os.system(command) to run the process, but some of them just hang. I would like to terminate the process after 15 seconds if it doesn't finish, but os.syst