Giter Club home page Giter Club logo

Comments (8)

binarymatt avatar binarymatt commented on September 28, 2024

can you describe what and where the change would be?

from pyres.

yashh avatar yashh commented on September 28, 2024

This could be a killer feature. Can we standardize the timestamp to use JSON timestamps?

from pyres.

mjrusso avatar mjrusso commented on September 28, 2024

Sure --

In Resque, timestamps are calculated with the following code:

Time.now.to_s

The result looks something like the following:

Thu Feb 18 23:42:16 -0500 2010

For example, when starting a worker, the following code is executed:

# Tell Redis we've started
def started!
  redis.set("worker:#{self}:started", Time.now.to_s)
end

And, as we would expect, this code creates a key-value pair that looks something like the following: worker:Macintosh-101.local:41166:default:started:Thu Feb 18 23:49:23 -0500 2010.

Now, when I try to run pyres_web with that key-value pair set in the database, the server will crash on any page that needs to render the timestamp. For example:

<type 'exceptions.ValueError'> occurred on '/workers/Macintosh-101.local:41166:default': time data 'Thu Feb 18 23:49:23 -0500 2010' does not match format '%Y-%m-%d %H:%M:%S'

Caused by:

File "/Library/Python/2.6/site-packages/pyres-0.5.0-py2.6.egg/pyres/worker.py", line 53, in _get_started
ds = datetime.datetime.strptime(datestring, '%Y-%m-%d %H:%M:%S')

Using the same timestamp format as returned by Ruby's Time.now.to_s would make this work. (This would need to be done everywhere that timestamps are generated.)

from pyres.

binarymatt avatar binarymatt commented on September 28, 2024

if someone wants to write up a patch, i'll be happy to take a look at it.

from pyres.

mjrusso avatar mjrusso commented on September 28, 2024

I will write a patch for this, hopefully in a week or so.

from pyres.

mjrusso avatar mjrusso commented on September 28, 2024

Turns out that this was a bit messier than I was hoping, so I reached out to the Resque folks. See here: http://github.com/defunkt/resque/issues#issue/60

We would have to change the following code to use Unix timestamps:

pyres.worker:

def _set_started(self, time):
    if time:
        self.resq.redis.set("resque:worker:%s:started" % self, time.strftime('%Y-%m-%d %H:%M:%S'))
    else:
        self.resq.redis.delete("resque:worker:%s:started" % self)

def _get_started(self):
    datestring = self.resq.redis.get("resque:worker:%s:started" % self)
    ds = None
    if datestring:
        ds = datetime.datetime.strptime(datestring, '%Y-%m-%d %H:%M:%S')
    return ds

pyres.failure.redis:

'failed_at' : str(datetime.datetime.now()),

And then there there might be a few places in pyres_web.

Can we get this into 0.7 or did you want to wait until the next version?

from pyres.

binarymatt avatar binarymatt commented on September 28, 2024

i think i might have this done. I'm working on some tests right now.

from pyres.

binarymatt avatar binarymatt commented on September 28, 2024

This is done and in master

from pyres.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.