I’m trying to do some multithreaded ruby programming on Windows, using
the pragprogrammers’ ruby167-5.exe installation. I’ve got MySQL
working too and I’m using the DBI in my code. The thing is, ruby
threads work fine if I don’t call any DBI code. But if I do call DBI
code, even if I completely close my connection before using any
threads, I get a “stack level too deep” error. When I remove the DBI
code, the threads work fine. Here is the threaded code:
···
THREADCOUNT = 5
threads = []
THREADCOUNT.times do |i|
threads << Thread.new do
puts “got here” + i.to_s
end
end
threads.each {|t| t.join }
It’s just a simple test to see if I can use threads. It works fine if
I don’t use the DBI, but if I call any DBI functions, it bombs on me
with an error like this:
…/BankDB.rb:6:in []': stack level too deep (SystemStackError) from ./BankDB.rb:10:in[]'
from ./BankDB.rb:10:in []' from ./BankDB.rb:10:in[]'
from ./BankDB.rb:10:in []' from ./BankDB.rb:10:in[]'
from ./BankDB.rb:10:in []' from ./BankDB.rb:10:in[]'
from ./BankDB.rb:10:in []' ... 722 levels... from ./BankDB.rb:10:in[]'
from ./BankDB.rb:10:in []' from ./BankDB.rb:34:inget_user_db’
from D:\FoxServ\www\bank\bin\test.rb:4
Does anybody know if there is a way to get around this?
I'm trying to do some multithreaded ruby programming on Windows, using
the pragprogrammers' ruby167-5.exe installation. I've got MySQL
working too and I'm using the DBI in my code. The thing is, ruby
threads work fine if I don't call any DBI code. But if I do call DBI
code, even if I completely close my connection before using any
threads, I get a "stack level too deep" error. When I remove the DBI
code, the threads work fine. Here is the threaded code:
Can you give the complete example, I can't reproduce it with DBD::Pg
begin
DBI.connect('dbi:Pg:dbname=imgd', $user, $pass) do |dbd|
dbd.prepare("select distinct map from map_location order by 1") do |sth|
sth.execute
p sth.column_names
sth.each do |m,|
p m
end
end
end
rescue DBI::Error
puts $!
end
THREADCOUNT = 5
threads =
THREADCOUNT.times do |i|
threads << Thread.new do
puts "got here" + i.to_s
end
end
It’s just a simple test to see if I can use threads. It works fine if
I don’t use the DBI, but if I call any DBI functions, it bombs on me
with an error like this:
…/BankDB.rb:6:in []': stack level too deep (SystemStackError) from ./BankDB.rb:10:in ’
from ./BankDB.rb:10:in []' from ./BankDB.rb:10:in ’
from ./BankDB.rb:10:in []' from ./BankDB.rb:10:in ’
from ./BankDB.rb:10:in []' from ./BankDB.rb:10:in ’
from ./BankDB.rb:10:in []' ... 722 levels... from ./BankDB.rb:10:in ’
from ./BankDB.rb:10:in []' from ./BankDB.rb:34:in get_user_db’
from D:\FoxServ\www\bank\bin\test.rb:4
Does anybody know if there is a way to get around this?
I’m trying to do some multithreaded ruby programming on Windows, using
the pragprogrammers’ ruby167-5.exe installation. I’ve got MySQL
working too and I’m using the DBI in my code. The thing is, ruby
threads work fine if I don’t call any DBI code. But if I do call DBI
code, even if I completely close my connection before using any
threads, I get a “stack level too deep” error. When I remove the DBI
code, the threads work fine. Here is the threaded code:
Can you give the complete example, I can’t reproduce it with DBD::Pg
I believe the problem is related to the Win32 port of ruby not having
complete support for ruby threads. I’m just wondering if anyone knows
a way around this, or if it is going to be fixed soon.
There was. Thanks for the tip and sorry for the trouble.
Carl
···
----- Original Message -----
From: “Eric Hodel” drbrain@segment7.net
To: “ruby-talk ML” ruby-talk@ruby-lang.org
Sent: Monday, November 04, 2002 1:23 PM
Subject: Re: “stack level too deep” error when trying to multithread in
win32 using dbi
What is the code for BankDB.rb, line 10 (the [] operator)?