eventmachine 1.0.0.beta.2-x86-mswin32-60 → 1.0.0.beta.3-x86-mswin32-60
Sign up to get free protection for your applications and to get access to all the features.
- data/.yardopts +3 -0
- data/Gemfile +1 -0
- data/eventmachine.gemspec +1 -3
- data/ext/cmain.cpp +4 -4
- data/ext/ed.cpp +13 -16
- data/ext/ed.h +9 -10
- data/ext/em.cpp +14 -24
- data/ext/eventmachine.h +2 -2
- data/ext/extconf.rb +1 -1
- data/ext/rubymain.cpp +8 -6
- data/lib/em/connection.rb +3 -1
- data/lib/em/pure_ruby.rb +17 -17
- data/lib/em/resolver.rb +186 -0
- data/lib/em/spawnable.rb +3 -7
- data/lib/em/version.rb +1 -1
- data/lib/eventmachine.rb +6 -4
- data/lib/jeventmachine.rb +1 -1
- data/tasks/package.rake +4 -1
- data/tasks/test.rake +1 -0
- data/tests/em_test_helper.rb +55 -0
- data/tests/test_attach.rb +46 -56
- data/tests/test_basic.rb +74 -96
- data/tests/test_channel.rb +2 -4
- data/tests/test_connection_count.rb +1 -3
- data/tests/test_defer.rb +13 -44
- data/tests/test_deferrable.rb +19 -19
- data/tests/test_epoll.rb +25 -55
- data/tests/test_error_handler.rb +10 -7
- data/tests/test_exc.rb +6 -33
- data/tests/test_file_watch.rb +51 -35
- data/tests/test_futures.rb +9 -37
- data/tests/test_get_sock_opt.rb +27 -20
- data/tests/test_handler_check.rb +1 -3
- data/tests/test_hc.rb +24 -59
- data/tests/test_httpclient.rb +27 -64
- data/tests/test_httpclient2.rb +1 -29
- data/tests/test_inactivity_timeout.rb +44 -40
- data/tests/test_kb.rb +26 -52
- data/tests/test_ltp.rb +23 -67
- data/tests/test_ltp2.rb +1 -30
- data/tests/test_next_tick.rb +1 -30
- data/tests/test_object_protocol.rb +8 -9
- data/tests/test_pause.rb +45 -37
- data/tests/test_pending_connect_timeout.rb +42 -38
- data/tests/test_process_watch.rb +1 -3
- data/tests/test_processes.rb +92 -110
- data/tests/test_proxy_connection.rb +128 -104
- data/tests/test_pure.rb +29 -75
- data/tests/test_queue.rb +2 -4
- data/tests/test_resolver.rb +55 -0
- data/tests/test_running.rb +1 -29
- data/tests/test_sasl.rb +7 -32
- data/tests/test_send_file.rb +162 -196
- data/tests/test_servers.rb +13 -56
- data/tests/test_smtpclient.rb +1 -29
- data/tests/test_smtpserver.rb +1 -29
- data/tests/test_spawn.rb +2 -31
- data/tests/test_ssl_args.rb +9 -10
- data/tests/test_ssl_methods.rb +1 -3
- data/tests/test_ssl_verify.rb +63 -63
- data/tests/test_tick_loop.rb +1 -1
- data/tests/test_timers.rb +52 -89
- data/tests/test_ud.rb +1 -29
- metadata +20 -10
- data/setup.rb +0 -1585
- data/tests/test_errors.rb +0 -82
- data/tests/testem.rb +0 -31
data/tests/test_error_handler.rb
CHANGED
@@ -1,10 +1,13 @@
|
|
1
|
-
|
2
|
-
require 'eventmachine'
|
3
|
-
require 'test/unit'
|
1
|
+
require 'em_test_helper'
|
4
2
|
|
5
3
|
class TestErrorHandler < Test::Unit::TestCase
|
4
|
+
def setup
|
5
|
+
@exception = Class.new(StandardError)
|
6
|
+
end
|
7
|
+
|
6
8
|
def test_error_handler
|
7
9
|
error = nil
|
10
|
+
|
8
11
|
EM.error_handler{ |e|
|
9
12
|
error = e
|
10
13
|
EM.error_handler(nil)
|
@@ -14,20 +17,20 @@ class TestErrorHandler < Test::Unit::TestCase
|
|
14
17
|
assert_nothing_raised do
|
15
18
|
EM.run{
|
16
19
|
EM.add_timer(0){
|
17
|
-
raise 'test'
|
20
|
+
raise @exception, 'test'
|
18
21
|
}
|
19
22
|
}
|
20
23
|
end
|
21
24
|
|
22
|
-
assert_equal error.class,
|
25
|
+
assert_equal error.class, @exception
|
23
26
|
assert_equal error.message, 'test'
|
24
27
|
end
|
25
28
|
|
26
29
|
def test_without_error_handler
|
27
|
-
assert_raise
|
30
|
+
assert_raise @exception do
|
28
31
|
EM.run{
|
29
32
|
EM.add_timer(0){
|
30
|
-
raise 'test'
|
33
|
+
raise @exception, 'test'
|
31
34
|
}
|
32
35
|
}
|
33
36
|
end
|
data/tests/test_exc.rb
CHANGED
@@ -1,44 +1,17 @@
|
|
1
|
-
|
2
|
-
#
|
3
|
-
# Author:: Francis Cianfrocca (gmail: blackhedd)
|
4
|
-
# Homepage:: http://rubyeventmachine.com
|
5
|
-
# Date:: 8 April 2006
|
6
|
-
#
|
7
|
-
# See EventMachine and EventMachine::Connection for documentation and
|
8
|
-
# usage examples.
|
9
|
-
#
|
10
|
-
#----------------------------------------------------------------------------
|
11
|
-
#
|
12
|
-
# Copyright (C) 2006-07 by Francis Cianfrocca. All Rights Reserved.
|
13
|
-
# Gmail: blackhedd
|
14
|
-
#
|
15
|
-
# This program is free software; you can redistribute it and/or modify
|
16
|
-
# it under the terms of either: 1) the GNU General Public License
|
17
|
-
# as published by the Free Software Foundation; either version 2 of the
|
18
|
-
# License, or (at your option) any later version; or 2) Ruby's License.
|
19
|
-
#
|
20
|
-
# See the file COPYING for complete licensing information.
|
21
|
-
#
|
22
|
-
#---------------------------------------------------------------------------
|
23
|
-
#
|
24
|
-
#
|
25
|
-
|
26
|
-
$:.unshift "../lib"
|
27
|
-
require 'eventmachine'
|
28
|
-
require 'test/unit'
|
1
|
+
require 'em_test_helper'
|
29
2
|
|
30
3
|
class TestSomeExceptions < Test::Unit::TestCase
|
31
4
|
|
32
|
-
# Read the commentary in
|
5
|
+
# Read the commentary in EM#run.
|
33
6
|
# This test exercises the ensure block in #run that makes sure
|
34
|
-
#
|
7
|
+
# EM#release_machine gets called even if an exception is
|
35
8
|
# thrown within the user code. Without the ensured call to release_machine,
|
36
|
-
# the second call to
|
9
|
+
# the second call to EM#run will fail with a C++ exception
|
37
10
|
# because the machine wasn't cleaned up properly.
|
38
11
|
|
39
12
|
def test_a
|
40
13
|
assert_raises(RuntimeError) {
|
41
|
-
|
14
|
+
EM.run {
|
42
15
|
raise "some exception"
|
43
16
|
}
|
44
17
|
}
|
@@ -46,7 +19,7 @@ class TestSomeExceptions < Test::Unit::TestCase
|
|
46
19
|
|
47
20
|
def test_b
|
48
21
|
assert_raises(RuntimeError) {
|
49
|
-
|
22
|
+
EM.run {
|
50
23
|
raise "some exception"
|
51
24
|
}
|
52
25
|
}
|
data/tests/test_file_watch.rb
CHANGED
@@ -1,49 +1,65 @@
|
|
1
|
-
|
2
|
-
require '
|
3
|
-
require 'test/unit'
|
1
|
+
require 'em_test_helper'
|
2
|
+
require 'tempfile'
|
4
3
|
|
5
4
|
class TestFileWatch < Test::Unit::TestCase
|
6
|
-
|
7
|
-
def
|
8
|
-
|
5
|
+
if windows?
|
6
|
+
def test_watch_file_raises_unsupported_error
|
7
|
+
assert_raises(EM::Unsupported) do
|
8
|
+
EM.run do
|
9
|
+
file = Tempfile.new("fake_file")
|
10
|
+
EM.watch_file(file.path)
|
11
|
+
end
|
12
|
+
end
|
9
13
|
end
|
10
|
-
|
11
|
-
|
14
|
+
elsif EM.respond_to? :watch_filename
|
15
|
+
module FileWatcher
|
16
|
+
def file_modified
|
17
|
+
$modified = true
|
18
|
+
end
|
19
|
+
def file_deleted
|
20
|
+
$deleted = true
|
21
|
+
end
|
22
|
+
def unbind
|
23
|
+
$unbind = true
|
24
|
+
EM.stop
|
25
|
+
end
|
12
26
|
end
|
13
|
-
|
14
|
-
|
15
|
-
EM.
|
27
|
+
|
28
|
+
def setup
|
29
|
+
EM.kqueue = true if EM.kqueue?
|
16
30
|
end
|
17
|
-
end
|
18
31
|
|
19
|
-
|
20
|
-
|
21
|
-
|
32
|
+
def teardown
|
33
|
+
EM.kqueue = false if EM.kqueue?
|
34
|
+
end
|
22
35
|
|
23
|
-
|
24
|
-
|
25
|
-
|
36
|
+
def test_events
|
37
|
+
EM.run{
|
38
|
+
file = Tempfile.new('em-watch')
|
39
|
+
$tmp_path = file.path
|
26
40
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
file = Tempfile.new('em-watch')
|
31
|
-
$tmp_path = file.path
|
41
|
+
# watch it
|
42
|
+
watch = EM.watch_file(file.path, FileWatcher)
|
43
|
+
$path = watch.path
|
32
44
|
|
33
|
-
|
34
|
-
|
35
|
-
$path = watch.path
|
45
|
+
# modify it
|
46
|
+
File.open(file.path, 'w'){ |f| f.puts 'hi' }
|
36
47
|
|
37
|
-
|
38
|
-
|
48
|
+
# delete it
|
49
|
+
EM.add_timer(0.01){ file.close; file.delete }
|
50
|
+
}
|
39
51
|
|
40
|
-
|
41
|
-
|
42
|
-
|
52
|
+
assert_equal($path, $tmp_path)
|
53
|
+
assert($modified)
|
54
|
+
assert($deleted)
|
55
|
+
assert($unbind)
|
56
|
+
end
|
57
|
+
else
|
58
|
+
warn "EM.watch_file not implemented, skipping tests in #{__FILE__}"
|
43
59
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
60
|
+
# Because some rubies will complain if a TestCase class has no tests
|
61
|
+
def test_em_watch_file_unsupported
|
62
|
+
assert true
|
63
|
+
end
|
48
64
|
end
|
49
65
|
end
|
data/tests/test_futures.rb
CHANGED
@@ -1,32 +1,4 @@
|
|
1
|
-
|
2
|
-
#
|
3
|
-
# Author:: Francis Cianfrocca (gmail: blackhedd)
|
4
|
-
# Homepage:: http://rubyeventmachine.com
|
5
|
-
# Date:: 8 April 2006
|
6
|
-
#
|
7
|
-
# See EventMachine and EventMachine::Connection for documentation and
|
8
|
-
# usage examples.
|
9
|
-
#
|
10
|
-
#----------------------------------------------------------------------------
|
11
|
-
#
|
12
|
-
# Copyright (C) 2006-07 by Francis Cianfrocca. All Rights Reserved.
|
13
|
-
# Gmail: blackhedd
|
14
|
-
#
|
15
|
-
# This program is free software; you can redistribute it and/or modify
|
16
|
-
# it under the terms of either: 1) the GNU General Public License
|
17
|
-
# as published by the Free Software Foundation; either version 2 of the
|
18
|
-
# License, or (at your option) any later version; or 2) Ruby's License.
|
19
|
-
#
|
20
|
-
# See the file COPYING for complete licensing information.
|
21
|
-
#
|
22
|
-
#---------------------------------------------------------------------------
|
23
|
-
#
|
24
|
-
#
|
25
|
-
#
|
26
|
-
|
27
|
-
$:.unshift "../lib"
|
28
|
-
require 'eventmachine'
|
29
|
-
require 'test/unit'
|
1
|
+
require 'em_test_helper'
|
30
2
|
|
31
3
|
class TestFutures < Test::Unit::TestCase
|
32
4
|
|
@@ -37,14 +9,14 @@ class TestFutures < Test::Unit::TestCase
|
|
37
9
|
end
|
38
10
|
|
39
11
|
def test_future
|
40
|
-
assert_equal(100,
|
12
|
+
assert_equal(100, EM::Deferrable.future(100) )
|
41
13
|
|
42
14
|
p1 = proc { 100 + 1 }
|
43
|
-
assert_equal(101,
|
15
|
+
assert_equal(101, EM::Deferrable.future(p1) )
|
44
16
|
end
|
45
17
|
|
46
18
|
class MyFuture
|
47
|
-
include
|
19
|
+
include EM::Deferrable
|
48
20
|
def initialize *args
|
49
21
|
super
|
50
22
|
set_deferred_status :succeeded, 40
|
@@ -52,7 +24,7 @@ class TestFutures < Test::Unit::TestCase
|
|
52
24
|
end
|
53
25
|
|
54
26
|
class MyErrorFuture
|
55
|
-
include
|
27
|
+
include EM::Deferrable
|
56
28
|
def initialize *args
|
57
29
|
super
|
58
30
|
set_deferred_status :failed, 41
|
@@ -67,7 +39,7 @@ class TestFutures < Test::Unit::TestCase
|
|
67
39
|
end
|
68
40
|
|
69
41
|
value = nil
|
70
|
-
|
42
|
+
EM::Deferrable.future my_future, proc {|v| value=v}
|
71
43
|
assert_equal( 40, value )
|
72
44
|
end
|
73
45
|
|
@@ -76,7 +48,7 @@ class TestFutures < Test::Unit::TestCase
|
|
76
48
|
# Call future with two additional arguments and they will be treated as a callback
|
77
49
|
# and an errback.
|
78
50
|
value = nil
|
79
|
-
|
51
|
+
EM::Deferrable.future MyErrorFuture.new, nil, proc {|v| value=v}
|
80
52
|
assert_equal( 41, value )
|
81
53
|
end
|
82
54
|
|
@@ -85,7 +57,7 @@ class TestFutures < Test::Unit::TestCase
|
|
85
57
|
# Call future with no additional arguments but with a block, and the block will be
|
86
58
|
# treated as a callback.
|
87
59
|
value = nil
|
88
|
-
|
60
|
+
EM::Deferrable.future MyFuture.new do |v|
|
89
61
|
value=v
|
90
62
|
end
|
91
63
|
assert_equal( 40, value )
|
@@ -93,7 +65,7 @@ class TestFutures < Test::Unit::TestCase
|
|
93
65
|
|
94
66
|
|
95
67
|
class RecursiveCallback
|
96
|
-
include
|
68
|
+
include EM::Deferrable
|
97
69
|
end
|
98
70
|
|
99
71
|
# A Deferrable callback can call #set_deferred_status to change the values
|
data/tests/test_get_sock_opt.rb
CHANGED
@@ -1,30 +1,37 @@
|
|
1
|
-
|
2
|
-
require 'eventmachine'
|
1
|
+
require 'em_test_helper'
|
3
2
|
require 'socket'
|
4
|
-
require 'test/unit'
|
5
3
|
|
6
4
|
class TestGetSockOpt < Test::Unit::TestCase
|
7
5
|
|
8
|
-
|
9
|
-
|
10
|
-
|
6
|
+
if EM.respond_to? :get_sock_opt
|
7
|
+
def setup
|
8
|
+
assert(!EM.reactor_running?)
|
9
|
+
end
|
11
10
|
|
12
|
-
|
13
|
-
|
14
|
-
|
11
|
+
def teardown
|
12
|
+
assert(!EM.reactor_running?)
|
13
|
+
end
|
14
|
+
|
15
|
+
#-------------------------------------
|
15
16
|
|
16
|
-
|
17
|
+
def test_get_sock_opt
|
18
|
+
test = self
|
19
|
+
EM.run do
|
20
|
+
EM.connect 'google.com', 80, Module.new {
|
21
|
+
define_method :connection_completed do
|
22
|
+
val = get_sock_opt Socket::SOL_SOCKET, Socket::SO_ERROR
|
23
|
+
test.assert_equal "\0\0\0\0", val
|
24
|
+
EM.stop
|
25
|
+
end
|
26
|
+
}
|
27
|
+
end
|
28
|
+
end
|
29
|
+
else
|
30
|
+
warn "EM.get_sock_opt not implemented, skipping tests in #{__FILE__}"
|
17
31
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
EM.connect 'google.com', 80, Module.new {
|
22
|
-
define_method :connection_completed do
|
23
|
-
val = get_sock_opt Socket::SOL_SOCKET, Socket::SO_ERROR
|
24
|
-
test.assert_equal "\0\0\0\0", val
|
25
|
-
EM.stop
|
26
|
-
end
|
27
|
-
}
|
32
|
+
# Because some rubies will complain if a TestCase class has no tests
|
33
|
+
def test_em_get_sock_opt_unsupported
|
34
|
+
assert true
|
28
35
|
end
|
29
36
|
end
|
30
37
|
end
|
data/tests/test_handler_check.rb
CHANGED
data/tests/test_hc.rb
CHANGED
@@ -1,38 +1,8 @@
|
|
1
|
-
|
2
|
-
#
|
3
|
-
# Author:: Francis Cianfrocca (gmail: blackhedd)
|
4
|
-
# Homepage:: http://rubyeventmachine.com
|
5
|
-
# Date:: 8 April 2006
|
6
|
-
#
|
7
|
-
# See EventMachine and EventMachine::Connection for documentation and
|
8
|
-
# usage examples.
|
9
|
-
#
|
10
|
-
#----------------------------------------------------------------------------
|
11
|
-
#
|
12
|
-
# Copyright (C) 2006-07 by Francis Cianfrocca. All Rights Reserved.
|
13
|
-
# Gmail: blackhedd
|
14
|
-
#
|
15
|
-
# This program is free software; you can redistribute it and/or modify
|
16
|
-
# it under the terms of either: 1) the GNU General Public License
|
17
|
-
# as published by the Free Software Foundation; either version 2 of the
|
18
|
-
# License, or (at your option) any later version; or 2) Ruby's License.
|
19
|
-
#
|
20
|
-
# See the file COPYING for complete licensing information.
|
21
|
-
#
|
22
|
-
#---------------------------------------------------------------------------
|
23
|
-
#
|
24
|
-
#
|
25
|
-
#
|
26
|
-
|
27
|
-
require 'eventmachine'
|
28
|
-
require 'test/unit'
|
1
|
+
require 'em_test_helper'
|
29
2
|
|
30
3
|
class TestHeaderAndContentProtocol < Test::Unit::TestCase
|
31
4
|
|
32
|
-
|
33
|
-
TestPort = 8905
|
34
|
-
|
35
|
-
class SimpleTest < EventMachine::Protocols::HeaderAndContentProtocol
|
5
|
+
class SimpleTest < EM::P::HeaderAndContentProtocol
|
36
6
|
attr_reader :first_header, :my_headers, :request
|
37
7
|
|
38
8
|
def receive_first_header_line hdr
|
@@ -51,19 +21,23 @@ class TestHeaderAndContentProtocol < Test::Unit::TestCase
|
|
51
21
|
|
52
22
|
class StopOnUnbind < EM::Connection
|
53
23
|
def unbind
|
54
|
-
EM.add_timer(0.
|
24
|
+
EM.add_timer(0.01) { EM.stop }
|
55
25
|
end
|
56
26
|
end
|
57
27
|
|
28
|
+
def setup
|
29
|
+
@port = next_port
|
30
|
+
end
|
31
|
+
|
58
32
|
def test_no_content
|
59
33
|
the_connection = nil
|
60
34
|
EM.run {
|
61
|
-
EM.start_server(
|
35
|
+
EM.start_server( "127.0.0.1", @port, SimpleTest ) do |conn|
|
62
36
|
the_connection = conn
|
63
37
|
end
|
64
38
|
setup_timeout
|
65
39
|
|
66
|
-
EM.connect
|
40
|
+
EM.connect "127.0.0.1", @port, StopOnUnbind do |c|
|
67
41
|
c.send_data [ "aaa\n", "bbb\r\n", "ccc\n", "\n" ].join
|
68
42
|
c.close_connection_after_writing
|
69
43
|
end
|
@@ -77,13 +51,13 @@ class TestHeaderAndContentProtocol < Test::Unit::TestCase
|
|
77
51
|
the_connection = nil
|
78
52
|
content = "A" * 50
|
79
53
|
headers = ["aaa", "bbb", "Content-length: #{content.length}", "ccc"]
|
80
|
-
|
81
|
-
|
54
|
+
EM.run {
|
55
|
+
EM.start_server( "127.0.0.1", @port, SimpleTest ) do |conn|
|
82
56
|
the_connection = conn
|
83
57
|
end
|
84
58
|
setup_timeout
|
85
59
|
|
86
|
-
EM.connect
|
60
|
+
EM.connect "127.0.0.1", @port, StopOnUnbind do |c|
|
87
61
|
headers.each { |h| c.send_data "#{h}\r\n" }
|
88
62
|
c.send_data "\n"
|
89
63
|
c.send_data content
|
@@ -99,13 +73,13 @@ class TestHeaderAndContentProtocol < Test::Unit::TestCase
|
|
99
73
|
the_connection = nil
|
100
74
|
content = "A" * 50
|
101
75
|
headers = ["aaa", "bbb", "Content-length: #{content.length}", "ccc"]
|
102
|
-
|
103
|
-
|
76
|
+
EM.run {
|
77
|
+
EM.start_server( "127.0.0.1", @port, SimpleTest ) do |conn|
|
104
78
|
the_connection = conn
|
105
79
|
end
|
106
80
|
setup_timeout
|
107
81
|
|
108
|
-
|
82
|
+
EM.connect( "127.0.0.1", @port, StopOnUnbind ) do |c|
|
109
83
|
5.times do
|
110
84
|
headers.each { |h| c.send_data "#{h}\r\n" }
|
111
85
|
c.send_data "\n"
|
@@ -125,20 +99,20 @@ class TestHeaderAndContentProtocol < Test::Unit::TestCase
|
|
125
99
|
# the_connection = nil
|
126
100
|
# content = "A" * 50
|
127
101
|
# headers = ["aaa", "bbb", ["Content-length: #{content.length}"]*2, "ccc"].flatten
|
128
|
-
#
|
129
|
-
#
|
102
|
+
# EM.run {
|
103
|
+
# EM.start_server( "127.0.0.1", @port, SimpleTest ) do |conn|
|
130
104
|
# the_connection = conn
|
131
105
|
# end
|
132
|
-
#
|
106
|
+
# EM.add_timer(4) {raise "test timed out"}
|
133
107
|
# test_proc = proc {
|
134
|
-
# t = TCPSocket.new
|
108
|
+
# t = TCPSocket.new "127.0.0.1", @port
|
135
109
|
# headers.each {|h| t.write "#{h}\r\n" }
|
136
110
|
# t.write "\n"
|
137
111
|
# t.write content
|
138
112
|
# t.close
|
139
113
|
# }
|
140
|
-
#
|
141
|
-
#
|
114
|
+
# EM.defer test_proc, proc {
|
115
|
+
# EM.stop
|
142
116
|
# }
|
143
117
|
# }
|
144
118
|
# end
|
@@ -154,13 +128,13 @@ class TestHeaderAndContentProtocol < Test::Unit::TestCase
|
|
154
128
|
"x-tempest-header:ddd"
|
155
129
|
]
|
156
130
|
|
157
|
-
|
158
|
-
|
131
|
+
EM.run {
|
132
|
+
EM.start_server( "127.0.0.1", @port, SimpleTest ) do |conn|
|
159
133
|
the_connection = conn
|
160
134
|
end
|
161
135
|
setup_timeout
|
162
136
|
|
163
|
-
|
137
|
+
EM.connect( "127.0.0.1", @port, StopOnUnbind ) do |c|
|
164
138
|
headers.each { |h| c.send_data "#{h}\r\n" }
|
165
139
|
c.send_data "\n"
|
166
140
|
c.send_data content
|
@@ -178,13 +152,4 @@ class TestHeaderAndContentProtocol < Test::Unit::TestCase
|
|
178
152
|
assert_equal(expect, hsh)
|
179
153
|
end
|
180
154
|
|
181
|
-
def setup_timeout(timeout = 4)
|
182
|
-
EM.schedule {
|
183
|
-
start_time = EM.current_time
|
184
|
-
EM.add_periodic_timer(0.01) {
|
185
|
-
raise "timeout" if EM.current_time - start_time >= timeout
|
186
|
-
}
|
187
|
-
}
|
188
|
-
end
|
189
|
-
|
190
155
|
end
|