Browse Source

Add timeout to urlopen in order to avoid "freeze" of the cron job

pull/309/head
Sebastien Maillard 9 years ago
parent
commit
430afc1d93
  1. 9
      dead_mans_switch_client/models/dead_mans_switch_client.py

9
dead_mans_switch_client/models/dead_mans_switch_client.py

@ -12,6 +12,8 @@ except ImportError:
import urllib2
from openerp import api, models
SEND_TIMEOUT = 60
class DeadMansSwitchClient(models.AbstractModel):
_name = 'dead.mans.switch.client'
@ -54,6 +56,10 @@ class DeadMansSwitchClient(models.AbstractModel):
if not url:
logger.error('No server configured!')
return
timeout = self.env['ir.config_parameter'].get_param(
'dead_mans_switch_client.send_timeout')
if not timeout:
timeout = SEND_TIMEOUT
data = self._get_data()
logger.debug('sending %s', data)
urllib2.urlopen(
@ -66,7 +72,8 @@ class DeadMansSwitchClient(models.AbstractModel):
}),
{
'Content-Type': 'application/json',
}))
}),
timeout)
@api.model
def _install_default_url(self):

Loading…
Cancel
Save