Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Psych (YAML) workaround #201

wants to merge 3 commits into


None yet
6 participants

pda commented Feb 3, 2011

See #199 for more information.

Psych is gradually becoming the default YAML parser in Ruby 1.9, but delayed_job does not like it at all. With RubyGems 1.5 and Bundler 1.0.10 loading Psych, it's getting harder to avoid.

If Psych is loaded before delayed_job, delayed_job fails to remove_method :to_yaml raising a NameError. The first commit, by benhoskings, guards against this.

The second commit sets YAML::ENGINE.yamler = "syck" so that delayed_job works properly if something has already set the yamler to "psych".

Tested in Ruby 1.9.2-p136 and Ruby 1.8.7-p330 with the delayed_job test suite and with a Rails 3.0.3 application under Bundler 1.0.10.


PS: sorry about the earlier pull request that wasn't quite there.

joshfng commented Feb 3, 2011

I can confirm that this patch works. I have testing it on my (earlier broken) production setups and all is working now. DJ workers starts, jobs insert, jobs get serialized and deserialized properly, and the workers are able to properly process the jobs once again.

Huge thank you. PS thanks for pheanstalk to :)

meeiw commented Feb 3, 2011

This patch fixed problems when DJ was trying deserializing Delayed::Job#handler

Tested with:
rubygems 1.5.0
bundler 1.0.10

Great job!


gaffneyc commented Feb 10, 2011

Changes look good, though I'm leaning in the direction of just fixing the underlying problem and adding support for psych.

pda commented Feb 10, 2011

It would be great to see full support for Psych, although I'd guess that would be a 2.2.x release.

It might be a good idea to include this workaround in a 2.1.4 point release, because:

  • Installation of the current latest gem will frustrate people.
  • People probably aren't comfortable using a patched release.
  • People version locked to e.g. "~> 2.1.0" wont get a future 2.2.x release.

.. just a thought :)

PS: thanks to you guys at Collective Idea for the great work on delayed_job


gaffneyc commented Feb 11, 2011

All good points! I'm going to dive in tomorrow and see what Psych support would take. If it's more than a little complex I'll pull in your changes and do a new release.

Either way it looks like people are having trouble with the new bundler and rails 3.0.4 so we need a new release tomorrow.


gaffneyc commented Feb 11, 2011

Psych integration doesn't look like it's going to be straight forward. I've merged the changes into master and will be cutting a new release shortly.


vantran commented Mar 25, 2011

We have this same problem, tried the patch and didn't seem to make a difference. Below is a snippet of the database value. Strange *id001 and !timestamp? Any advice to fix this?

- !ruby/ActiveRecord:Subscription 
    created_at: &id001 2011-03-25 08:21:04.444279 Z
    updated_at: *id001
    begin_date: !timestamp 03/26/2011

meeiw commented Mar 29, 2011

`*id001" is yaml syntax

check out "alias indicators" @ http://www.yaml.org/refcard.html

vantran commented Mar 29, 2011

You're right, I just realized that. But the !timestamp indicates broken yaml. I have done a fix here

This issue was closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment