Comments (8)
can you describe what and where the change would be?
from pyres.
This could be a killer feature. Can we standardize the timestamp to use JSON timestamps?
from pyres.
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.
if someone wants to write up a patch, i'll be happy to take a look at it.
from pyres.
I will write a patch for this, hopefully in a week or so.
from pyres.
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.
i think i might have this done. I'm working on some tests right now.
from pyres.
This is done and in master
from pyres.
Related Issues (20)
- cannot create ResQ instance if Redis requires a password HOT 5
- Releasing a new version HOT 7
- worker pool
- document perform hooks
- Speed & More Pythonic HOT 1
- "No module named xxxx" raised when enqueue a local class HOT 3
- merge work in from pinterest branch HOT 4
- pyres_worker script can't connect to password-protected redis server
- It seems that pyres(1.4.1) installed by pip is not the same as the 1.4.1 version of git HOT 1
- Python 3 Support HOT 2
- Remove a Delayed Job
- is there a before_first_fork or similar hook? HOT 2
- release new version HOT 3
- Compatibility with Resque implementations ? HOT 8
- Why doesn't after_perform run when an exception is raised?
- retry wont work if retry_timeout not set, is this intentional?
- Module Import Error HOT 1
- Docs link broken HOT 3
- Is this project still active? HOT 4
- AttributeError: 'int' object has no attribute 'iteritems'
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pyres.