|
|
@ -257,11 +257,9 @@ class Worker(object):
|
|
|
|
p.expire(self.key, 60)
|
|
|
|
p.expire(self.key, 60)
|
|
|
|
p.execute()
|
|
|
|
p.execute()
|
|
|
|
|
|
|
|
|
|
|
|
def set_warm_shutdown_requested_date(self):
|
|
|
|
def set_shutdown_requested_date(self):
|
|
|
|
"""Sets the date on which the worker received a warm shutdown request"""
|
|
|
|
"""Sets the date on which the worker received a (warm) shutdown request"""
|
|
|
|
with self.connection._pipeline() as p:
|
|
|
|
self.connection.hset(self.key, 'shutdown_requested_date', utcformat(utcnow()))
|
|
|
|
p.hset(self.key, 'warm_shutdown_requested_at', utcformat(utcnow()))
|
|
|
|
|
|
|
|
p.execute()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@property
|
|
|
|
@property
|
|
|
|
def birth_date(self):
|
|
|
|
def birth_date(self):
|
|
|
@ -271,11 +269,11 @@ class Worker(object):
|
|
|
|
return utcparse(as_text(birth_timestamp))
|
|
|
|
return utcparse(as_text(birth_timestamp))
|
|
|
|
|
|
|
|
|
|
|
|
@property
|
|
|
|
@property
|
|
|
|
def warm_shutdown_requested_date(self):
|
|
|
|
def shutdown_requested_date(self):
|
|
|
|
"""Fetches warm_shutdown_requested_date from Redis."""
|
|
|
|
"""Fetches shutdown_requested_date from Redis."""
|
|
|
|
warm_shutdown_requested_timestamp = self.connection.hget(self.key, 'warm_shutdown_requested_at')
|
|
|
|
shutdown_requested_timestamp = self.connection.hget(self.key, 'shutdown_requested_date')
|
|
|
|
if warm_shutdown_requested_timestamp is not None:
|
|
|
|
if shutdown_requested_timestamp is not None:
|
|
|
|
return utcparse(as_text(warm_shutdown_requested_timestamp))
|
|
|
|
return utcparse(as_text(shutdown_requested_timestamp))
|
|
|
|
|
|
|
|
|
|
|
|
@property
|
|
|
|
@property
|
|
|
|
def death_date(self):
|
|
|
|
def death_date(self):
|
|
|
@ -373,7 +371,7 @@ class Worker(object):
|
|
|
|
# finish before shutting down and save the request in redis
|
|
|
|
# finish before shutting down and save the request in redis
|
|
|
|
if self.get_state() == 'busy':
|
|
|
|
if self.get_state() == 'busy':
|
|
|
|
self._stop_requested = True
|
|
|
|
self._stop_requested = True
|
|
|
|
self.set_warm_shutdown_requested_date()
|
|
|
|
self.set_shutdown_requested_date()
|
|
|
|
self.log.debug('Stopping after current horse is finished. '
|
|
|
|
self.log.debug('Stopping after current horse is finished. '
|
|
|
|
'Press Ctrl+C again for a cold shutdown.')
|
|
|
|
'Press Ctrl+C again for a cold shutdown.')
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|