Data type mismatch class method <-> EM reactor

7 views
Skip to first unread message

Christoph Pilka

unread,
May 16, 2012, 8:54:58 AM5/16/12
to EventMachine
Hi folks. I think it's a newbie question but why doesn't the EM loop
get the same data struc the callback in the function above returns?
https://gist.github.com/2709886 line 26 and 39 *confused*

Iñaki Baz Castillo

unread,
May 16, 2012, 12:46:22 PM5/16/12
to eventm...@googlegroups.com
2012/5/16 Christoph Pilka <c.p...@asconix.com>:
> Hi folks. I think it's a newbie question but why doesn't the EM loop
> get the same data struc the callback in the function above returns?
> https://gist.github.com/2709886 line 26 and 39 *confused*

What is so extrange?


response = resp.response
json = StringIO.new response
parser = Yajl::Parser.new
pool.proxies = parser.parse(json)
puts pool.proxies.class # -> returns Array


pool.proxies is the result of a JSON parsing and it's an array (it
could also be a Hash).


pool = MassiveProxy::ProxyPool.get(100)
pool.callback do |p|
puts p.class # -> returns EventMachine::HttpClient


p is an elemento within pool, which is a EM::HttpClient.


*Why* should both be the same class?

--
Iñaki Baz Castillo
<i...@aliax.net>

Christoph Pilka

unread,
May 18, 2012, 11:05:50 AM5/18/12
to EventMachine
Thanks for the reply. OK, I've stripped down the example to these both

* https://gist.github.com/2710575 (returrns different objects)
* https://gist.github.com/2710583 (returns same object)

It seems to be important to create the Object first and then call its
method in the EM loop instead of calling a method which should
initialize the new object.

Cheerio,
Chris

On May 16, 6:46 pm, Iñaki Baz Castillo <i...@aliax.net> wrote:
> 2012/5/16 Christoph Pilka <c.pi...@asconix.com>:
>
> > Hi folks. I think it's a newbie question but why doesn't the EM loop
> > get the same data struc the callback in the function above returns?
> >https://gist.github.com/2709886line 26 and 39 *confused*
Reply all
Reply to author
Forward
0 new messages