Change of behaviour for sleep(0) in 1.9

S

Sean O'Halpin

Hi,

Just thought I'd share this to save anyone else the bafflement it caused me.

In ruby 1.8.x and jruby, sleep(0) means do not sleep at all. In 1.9,
it appears to mean sleep forever.

In both cases, sleep with no arguments means sleep forever.

Perhaps differing interpretations of this ambiguous documentation from ri?

"Zero arguments causes sleep to sleep forever."

Regards,
Sean
 
I

Iñaki Baz Castillo

El Martes 31 Marzo 2009, Sean O'Halpin escribi=F3:
Hi,

Just thought I'd share this to save anyone else the bafflement it caused
me.

In ruby 1.8.x and jruby, sleep(0) means do not sleep at all. In 1.9,
it appears to mean sleep forever.

I've tested it in Ruby 1.9.1 and sleep(0) means do not sleep at all.

Perhaps differing interpretations of this ambiguous documentation from ri?

"Zero arguments causes sleep to sleep forever."

This must be a doc bug.


=2D-=20
I=F1aki Baz Castillo <[email protected]>
 
S

Sean O'Halpin

El Martes 31 Marzo 2009, Sean O'Halpin escribi=F3:

I've tested it in Ruby 1.9.1 and sleep(0) means do not sleep at all.

Hmmm. Just tested on Ubuntu 8.04 and sleep(0) works as expected in
all versions (i.e. it doesn't wait). However, this is what I get on
Mac OS X 10.4:

$ multiruby -rtimeout -e 'Timeout::timeout(2) { sleep(0) }'

[snip working versions]

VERSION =3D v1_9_1_0
CMD =3D ~/.multiruby/install/v1_9_1_0/bin/ruby -rtimeout -e
Timeout::timeout(2) { sleep(0) }

-e:1:in `sleep': execution expired (Timeout::Error)
from -e:1:in `block in <main>'
from -e:1:in `<main>'

RESULT =3D 256

TOTAL RESULT =3D 1 failures out of 5

Passed: jruby-1.2.0RC2, jruby-1.1.6, v1_8_6_110, 1.8.7-p72
Failed: v1_9_1_0
$ uname -a
Darwin xxxx 8.11.1 Darwin Kernel Version 8.11.1: Wed Oct 10 18:23:28
PDT 2007; root:xnu-792.25.20~1/RELEASE_I386 i386 i386

I guess I should file a bug report.

Regards,
Sean
 
R

Robert Klemme

2009/4/1 Sean O'Halpin said:
El Martes 31 Marzo 2009, Sean O'Halpin escribi=F3:

I've tested it in Ruby 1.9.1 and sleep(0) means do not sleep at all.

Hmmm. =A0Just tested on Ubuntu 8.04 and sleep(0) works as expected in
all versions (i.e. it doesn't wait). However, this is what I get on
Mac OS X 10.4:

$ multiruby -rtimeout -e 'Timeout::timeout(2) { sleep(0) }'

[snip working versions]

VERSION =3D v1_9_1_0
CMD =A0 =A0 =3D ~/.multiruby/install/v1_9_1_0/bin/ruby -rtimeout -e
Timeout::timeout(2) { sleep(0) }

-e:1:in `sleep': execution expired (Timeout::Error)
=A0 =A0 =A0 =A0from -e:1:in `block in <main>'
=A0 =A0 =A0 =A0from -e:1:in `<main>'

RESULT =3D 256

TOTAL RESULT =3D 1 failures out of 5

Passed: jruby-1.2.0RC2, jruby-1.1.6, v1_8_6_110, 1.8.7-p72
Failed: v1_9_1_0

Hm, works for me:

15:49:23 bas$ allruby -e 'puts Time.now; sleep 0; puts Time.now'
CYGWIN_NT-5.1 padrklemme1 1.5.25(0.156/4/2) 2008-06-12 19:34 i686 Cygwin
ruby 1.8.7 (2008-08-11 patchlevel 72) [i386-cygwin]
Wed Apr 01 15:49:24 +0200 2009
Wed Apr 01 15:49:24 +0200 2009
ruby 1.9.1p0 (2009-01-30 revision 21907) [i386-cygwin]
2009-04-01 15:49:25 +0100
2009-04-01 15:49:25 +0100
15:49:25 bas$

Cheers

robert


--=20
remember.guy do |as, often| as.you_can - without end
 
S

Sean O'Halpin

Hm, works for me:

15:49:23 bas$ allruby -e 'puts Time.now; sleep 0; puts Time.now'
CYGWIN_NT-5.1 padrklemme1 1.5.25(0.156/4/2) 2008-06-12 19:34 i686 Cygwin

Looks like a Mac OSX thing then. I've filed a bug report. Is there
anyone else out there with ruby 1.9 on OSX (10.4 or 10.5) who can
confirm that this is a problem?
 
A

Adam Gardner

Sean said:
Looks like a Mac OSX thing then. I've filed a bug report. Is there
anyone else out there with ruby 1.9 on OSX (10.4 or 10.5) who can
confirm that this is a problem?

$ uname -a
Darwin Machine.local 8.11.0 Darwin Kernel Version 8.11.0: Wed Oct 10
18:26:00 PDT 2007; root:xnu-792.24.17~1/RELEASE_PPC Power Macintosh
powerpc

$ ruby-1.9 -v
ruby 1.9.1p0 (2009-01-30 revision 21907) [powerpc-darwin8.11.0]

$ ruby-1.9 -r Timeout -e 'Timeout.timeout(1) {sleep(0)}'
-e:1:in `sleep': execution expired (Timeout::Error)
from -e:1:in `block in <main>'
from -e:1:in `<main>'
$

Seems to be a problem here, too.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,776
Messages
2,569,602
Members
45,183
Latest member
OrderGlycoEase

Latest Threads

Top