Browse Source

Merge pull request #309 from seb-elico/8.0-dms-add-send-timeout

Add timeout to urlopen in order to avoid "freeze" of the cron job
pull/184/merge
Stefan Rijnhart (Opener) 9 years ago
parent
commit
e4beae4c4f
  1. 7
      dead_mans_switch_client/models/dead_mans_switch_client.py

7
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,8 @@ 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', SEND_TIMEOUT)
data = self._get_data()
logger.debug('sending %s', data)
urllib2.urlopen(
@ -66,7 +70,8 @@ class DeadMansSwitchClient(models.AbstractModel):
}),
{
'Content-Type': 'application/json',
}))
}),
timeout)
@api.model
def _install_default_url(self):

Loading…
Cancel
Save