What's "io/nonblock"

G

Gavin Sinclair

Ara's "session" package tries to require 'io/nonblock' and fails on my
machine. Google reveals nothing very instructive. Anyone know what
it is?

Thanks,
Gavin
 
G

Gavin Sinclair

Ara's "session" package tries to require 'io/nonblock' and fails on my
machine. Google reveals nothing very instructive. Anyone know what
it is?

Chad Fowler knows what it is, and told me it's standard with 1.8.
Yippee. I reinstalled Ruby (latest CVS 1.8 branch), even though my
existing Ruby was not yet one month old, and here is the relevant
section from the output:

installing io/wait
make[1]: Entering directory `/home/gavin/Projects/ruby18/ext/io/wait'
make[1]: Nothing to be done for `install'.
make[1]: Leaving directory `/home/gavin/Projects/ruby18/ext/io/wait'

Problem, that.

Cheers,
Gavin
 
M

Michael Granger

Ara's "session" package tries to require 'io/nonblock' and fails on my
machine. Google reveals nothing very instructive. Anyone know what
it is?

[...]
installing io/wait
make[1]: Entering directory `/home/gavin/Projects/ruby18/ext/io/wait'
make[1]: Nothing to be done for `install'.
make[1]: Leaving directory `/home/gavin/Projects/ruby18/ext/io/wait'

Problem, that.

A problem, perhaps, but io/nonblock.rb is installed from
ext/io/wait/lib/, and is, as its name suggests, a plain Ruby file. It
doesn't appear to require io/wait, either, so you should be okay with
just installing it by itself to get 'session' working.
 
A

Ara.T.Howard

Ara's "session" package tries to require 'io/nonblock' and fails on my
machine. Google reveals nothing very instructive. Anyone know what
it is?

[...]
installing io/wait
make[1]: Entering directory `/home/gavin/Projects/ruby18/ext/io/wait'
make[1]: Nothing to be done for `install'.
make[1]: Leaving directory `/home/gavin/Projects/ruby18/ext/io/wait'

Problem, that.

A problem, perhaps, but io/nonblock.rb is installed from
ext/io/wait/lib/, and is, as its name suggests, a plain Ruby file. It
doesn't appear to require io/wait, either, so you should be okay with
just installing it by itself to get 'session' working.

would do - but __i__ require io/wait as well. the truth is i currently don't
really need both: my original design used nonblock, but this is broken in
threads, the lastest uses IO.ready?, which you get from io/wait:


from the source

<snip>
# this is the desired call - but threads block on it!
#iodat[:io].nonblock{ buf = iodat[:io].read }

# 2.1.5
#sleep(0.042) and Thread.pass until iodat[:io].ready?
#buf << iodat[:io].getc while iodat[:io].ready?

# 2.1.6
# decided to go ahead and read lines since
# - loop only terminates when cmd_end_pat has been found and this
# must be newline terminated
# - although this will block mid-line in the case of parital lines we
# know that, eventually, a newline will appear and this delay is
# acceptable so we can make larger (line buffered) reads instead of
# character ones. eventually i'd like to use io.nonblock{} to read
# 'as much as is there' but this does not play well with threads at the
# moment
buf << iodat[:io].gets while iodat[:io].ready?
</snip>


the semantics i'd like to have are 'read as much data as is possible, even a
single character, but don't block on the read'. this is what

iodat[:io].nonblock{ buf = iodat[:io].read }

should do. but in a thread it blocks. there was a few postings on this 2
months ago by me, nobu i think, and tanaka akira if you feel like searching...

in any case = you could acutally commnet out the 'require "io/nonblock"' and
it would be fine. but i hope to use this in future versions...

weird that you were lacking it - my old 18 seems to have it...

oh well.

cheers.

-a
--
===============================================================================
| EMAIL :: Ara [dot] T [dot] Howard [at] noaa [dot] gov
| PHONE :: 303.497.6469
| ADDRESS :: E/GC2 325 Broadway, Boulder, CO 80305-3328
| URL :: http://www.ngdc.noaa.gov/stp/
| TRY :: for l in ruby perl;do $l -e "print \"\x3a\x2d\x29\x0a\"";done
===============================================================================
 

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
474,145
Messages
2,570,824
Members
47,371
Latest member
Brkaa

Latest Threads

Top