Skip to content

separate fiber yielding and em-synchrony? #8

bmidgley opened this Issue Aug 10, 2012 · 3 comments

2 participants


The last time I tried em-synchrony, it broke dns lookup with its monkeypatching.

Is it possible to get the fiber-yielding behavior of your pg client without any of the monkeypatching ugliness of em-synchrony?

royaltm commented Aug 11, 2012

Hmm... maybe I didn't state it clearly but EM-Synchrony is optional.

You may require 'em-synchrony/pg' and benefit from fiber-aware pg driver without the need of EM-Synchrony gem.

However without em-synchrony you must remember:

  1. to wrap with e.g.:

    require 'em-synchrony/pg' do do
        ... your stuff goes here
  2. you should also provide some kind of connection pool (you may borrow it from EM-Synchrony) for proper handling of fiber-concurrency.


My advice is to try the latest em-synchrony anyway, perhaps it's DNS issues have been resolved.


Thanks for the response. I did see em-synchrony is optional but it's not clear what you end up with when not using it. em-synchrony is just too dramatic and risky for our project. I don't like that when it (silently) fails to patch something then you get different behavior from the same API calls.

We have rack fiber pool and we also create a fiber inside every em callback, so we're always running in a yieldable fiber.

Is there code that demonstrates patching active record to use yielding calls?

royaltm commented Aug 11, 2012

Yes, there is in one of those earlier em-postgres implementations:

I don't use ActiveRecord myself (IMO too much unnecessary layers, I use my own ORM).
Though it would be great If you happen to adapt leftbee/em-postgresql-adapter's ActiveRecord Patch to ruby-em-pg-client. If you would contribute of course :).
I'm aware ActiveRecord is popular these days, but I don't really have the time to develop something i'm not using.

@royaltm royaltm closed this Aug 31, 2013
@royaltm royaltm referenced this issue in fl00r/em-pg-sequel Jan 1, 2014

em-pg-client 0.3 update #6

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.