old_contents: """Tasks module
  
  All tasks run via external message queue (via celery) are defined
  within.
  
  NB: a celery worker must be started for these to ever return.  See
  `celery_worker.py`
  
  """
  from requests import Request, Session
  from requests.exceptions import RequestException
  from celery.utils.log import get_task_logger
  from .extensions import celery
  
  # To debug, stop the celeryd running out of /etc/init, start in console:
  #   celery worker -A portal.celery_worker.celery --loglevel=debug
  # Import rdb and use like pdb:
  #   from celery.contrib import rdb
  #   rdb.set_trace()
  # Follow instructions from celery console, i.e. telnet 127.0.0.1 6900
  
  logger = get_task_logger(__name__)
  
  
  @celery.task
  def add(x, y):
      return x + y
  
  @celery.task(bind=True)
  def post_request(self, url, data, timeout=10, retries=3):
      """Wrap requests.post for asyncronous posts - includes timeout & retry"""
      logger.debug("task: %s retries:%s", self.request.id, self.request.retries)
  
      s = Session()
      req = Request('POST', url, data=data)
      prepped = req.prepare()
      try:
          resp = s.send(prepped, timeout=timeout)
          if resp.status_code < 400:
              logger.info("{} received from {}".format(resp.status_code, url))
          else:
              logger.error("{} received from {}".format(resp.status_cod, url))
  
      except RequestException as exc:
          """Typically raised on timeout or connection error
  
          retry after countdown seconds unless retry threshold has been exceeded
          """
          logger.warn("{} on {}".format(exc.message, url))
          if self.request.retries < retries:
              raise self.retry(exc=exc, countdown=20)
          else:
              logger.error("max retries exceeded for {}, last failure: {}".\
                           format(url, exc))
      except Exception as exc:
          logger.error("Unexpected exception on {} : {}".format(url, exc))
  
new_contents: """Tasks module
  
  All tasks run via external message queue (via celery) are defined
  within.
  
  NB: a celery worker must be started for these to ever return.  See
  `celery_worker.py`
  
  """
  from requests import Request, Session
  from requests.exceptions import RequestException
  from celery.utils.log import get_task_logger
  from .extensions import celery
  
  # To debug, stop the celeryd running out of /etc/init, start in console:
  #   celery worker -A portal.celery_worker.celery --loglevel=debug
  # Import rdb and use like pdb:
  #   from celery.contrib import rdb
  #   rdb.set_trace()
  # Follow instructions from celery console, i.e. telnet 127.0.0.1 6900
  
  logger = get_task_logger(__name__)
  
  
  @celery.task
  def add(x, y):
      return x + y
  
  @celery.task(bind=True)
  def post_request(self, url, data, timeout=10, retries=3):
      """Wrap requests.post for asyncronous posts - includes timeout & retry"""
      logger.debug("task: %s retries:%s", self.request.id, self.request.retries)
  
      s = Session()
      req = Request('POST', url, data=data)
      prepped = req.prepare()
      try:
          resp = s.send(prepped, timeout=timeout)
          if resp.status_code < 400:
              logger.info("{} received from {}".format(resp.status_code, url))
          else:
              logger.error("{} received from {}".format(resp.status_code, url))
  
      except RequestException as exc:
          """Typically raised on timeout or connection error
  
          retry after countdown seconds unless retry threshold has been exceeded
          """
          logger.warn("{} on {}".format(exc.message, url))
          if self.request.retries < retries:
              raise self.retry(exc=exc, countdown=20)
          else:
              logger.error("max retries exceeded for {}, last failure: {}".\
                           format(url, exc))
      except Exception as exc:
          logger.error("Unexpected exception on {} : {}".format(url, exc))
  
subject: Fix typo