Created
September 15, 2011 21:08
-
-
Save aq1018/1220485 to your computer and use it in GitHub Desktop.
ruby-oci8 Runtime Error "executing in another thread"
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This will trigger Runtime Error "executing in another thread" from ruby-oci8 | |
# The cause is Timeout interrupted the rb_thread_blocking_region() and causing | |
# oci8_unblock_func() to be run, however, svcctx->executing_thread is not set | |
# to nil, causing the client to get into a bad state. | |
# See http://rubyforge.org/forum/forum.php?thread_id=50112&forum_id=1078 | |
require 'rubygems' | |
require 'oci8' | |
require 'timeout' | |
puts "Create DB Connection" | |
conn = OCI8.new('user', 'pass', 'db') | |
conn.non_blocking = true | |
puts "1111111111111111111111111111111" | |
cursor = conn.exec('long db execution to cause timeout') | |
begin | |
Timeout.timeout(1) do | |
puts "fetching..." | |
while r = cursor.fetch | |
end | |
end | |
rescue Timeout::Error | |
puts "DB Timed out" | |
ensure | |
puts "Closing cursor" | |
cursor.close | |
puts "Cursor is closed" | |
end | |
puts "22222222222222222222222222222222" | |
cursor = conn.exec('long db execution to cause timeout') | |
puts "start fetching..." | |
while r = cursor.fetch | |
end | |
puts "close cursor" | |
cursor.close |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment