コード例 #1
0
 def _process_child(self, path, request, quiet=True):
     """Receives the result of a child data fetch request."""
     job = None
     try:
         raw_data, node_stat = request.get()
         job_data = misc.decode_json(raw_data)
         job_created_on = misc.millis_to_datetime(node_stat.ctime)
         try:
             job_priority = job_data['priority']
             job_priority = base.JobPriority.convert(job_priority)
         except KeyError:
             job_priority = base.JobPriority.NORMAL
         job_uuid = job_data['uuid']
         job_name = job_data['name']
     except (ValueError, TypeError, KeyError):
         with excutils.save_and_reraise_exception(reraise=not quiet):
             LOG.warning("Incorrectly formatted job data found at path: %s",
                         path,
                         exc_info=True)
     except self._client.handler.timeout_exception:
         with excutils.save_and_reraise_exception(reraise=not quiet):
             LOG.warning(
                 "Operation timed out fetching job data from"
                 " from path: %s",
                 path,
                 exc_info=True)
     except k_exceptions.SessionExpiredError:
         with excutils.save_and_reraise_exception(reraise=not quiet):
             LOG.warning("Session expired fetching job data from path: %s",
                         path,
                         exc_info=True)
     except k_exceptions.NoNodeError:
         LOG.debug(
             "No job node found at path: %s, it must have"
             " disappeared or was removed", path)
     except k_exceptions.KazooException:
         with excutils.save_and_reraise_exception(reraise=not quiet):
             LOG.warning("Internal error fetching job data from path: %s",
                         path,
                         exc_info=True)
     else:
         with self._job_cond:
             # Now we can officially check if someone already placed this
             # jobs information into the known job set (if it's already
             # existing then just leave it alone).
             if path not in self._known_jobs:
                 job = ZookeeperJob(self,
                                    job_name,
                                    self._client,
                                    path,
                                    backend=self._persistence,
                                    uuid=job_uuid,
                                    book_data=job_data.get("book"),
                                    details=job_data.get("details", {}),
                                    created_on=job_created_on,
                                    priority=job_priority)
                 self._known_jobs[path] = job
                 self._job_cond.notify_all()
     if job is not None:
         self._try_emit(base.POSTED, details={'job': job})
コード例 #2
0
    def test_posting_dates(self, mock_dt):
        epoch = misc.millis_to_datetime(0)
        mock_dt.return_value = epoch

        with base.connect_close(self.board):
            j = self.board.post('test', p_utils.temporary_log_book())
            self.assertEqual(epoch, j.created_on)
            self.assertEqual(epoch, j.last_modified)

        self.assertTrue(mock_dt.called)
コード例 #3
0
    def test_posting_dates(self, mock_dt):
        epoch = misc.millis_to_datetime(0)
        mock_dt.return_value = epoch

        with connect_close(self.board):
            j = self.board.post('test', p_utils.temporary_log_book())
            self.assertEqual(epoch, j.created_on)
            self.assertEqual(epoch, j.last_modified)

        self.assertTrue(mock_dt.called)
コード例 #4
0
 def _process_child(self, path, request, quiet=True):
     """Receives the result of a child data fetch request."""
     job = None
     try:
         raw_data, node_stat = request.get()
         job_data = misc.decode_json(raw_data)
         job_created_on = misc.millis_to_datetime(node_stat.ctime)
         try:
             job_priority = job_data['priority']
             job_priority = base.JobPriority.convert(job_priority)
         except KeyError:
             job_priority = base.JobPriority.NORMAL
         job_uuid = job_data['uuid']
         job_name = job_data['name']
     except (ValueError, TypeError, KeyError):
         with excutils.save_and_reraise_exception(reraise=not quiet):
             LOG.warning("Incorrectly formatted job data found at path: %s",
                         path, exc_info=True)
     except self._client.handler.timeout_exception:
         with excutils.save_and_reraise_exception(reraise=not quiet):
             LOG.warning("Operation timed out fetching job data from"
                         " from path: %s",
                         path, exc_info=True)
     except k_exceptions.SessionExpiredError:
         with excutils.save_and_reraise_exception(reraise=not quiet):
             LOG.warning("Session expired fetching job data from path: %s",
                         path, exc_info=True)
     except k_exceptions.NoNodeError:
         LOG.debug("No job node found at path: %s, it must have"
                   " disappeared or was removed", path)
     except k_exceptions.KazooException:
         with excutils.save_and_reraise_exception(reraise=not quiet):
             LOG.warning("Internal error fetching job data from path: %s",
                         path, exc_info=True)
     else:
         with self._job_cond:
             # Now we can officially check if someone already placed this
             # jobs information into the known job set (if it's already
             # existing then just leave it alone).
             if path not in self._known_jobs:
                 job = ZookeeperJob(self, job_name,
                                    self._client, path,
                                    backend=self._persistence,
                                    uuid=job_uuid,
                                    book_data=job_data.get("book"),
                                    details=job_data.get("details", {}),
                                    created_on=job_created_on,
                                    priority=job_priority)
                 self._known_jobs[path] = job
                 self._job_cond.notify_all()
     if job is not None:
         self._try_emit(base.POSTED, details={'job': job})
コード例 #5
0
ファイル: impl_zookeeper.py プロジェクト: TheSriram/taskflow
 def _process_child(self, path, request):
     """Receives the result of a child data fetch request."""
     job = None
     try:
         raw_data, node_stat = request.get()
         job_data = misc.decode_json(raw_data)
         created_on = misc.millis_to_datetime(node_stat.ctime)
     except (ValueError, TypeError, KeyError):
         LOG.warn("Incorrectly formatted job data found at path: %s",
                  path, exc_info=True)
     except self._client.handler.timeout_exception:
         LOG.warn("Operation timed out fetching job data from path: %s",
                  path, exc_info=True)
     except k_exceptions.SessionExpiredError:
         LOG.warn("Session expired fetching job data from path: %s", path,
                  exc_info=True)
     except k_exceptions.NoNodeError:
         LOG.debug("No job node found at path: %s, it must have"
                   " disappeared or was removed", path)
     except k_exceptions.KazooException:
         LOG.warn("Internal error fetching job data from path: %s",
                  path, exc_info=True)
     else:
         self._job_cond.acquire()
         try:
             # Now we can offically check if someone already placed this
             # jobs information into the known job set (if it's already
             # existing then just leave it alone).
             if path not in self._known_jobs:
                 job = ZookeeperJob(job_data['name'], self,
                                    self._client, self._persistence, path,
                                    uuid=job_data['uuid'],
                                    book_data=job_data.get("book"),
                                    details=job_data.get("details", {}),
                                    created_on=created_on)
                 self._known_jobs[path] = job
                 self._job_cond.notify_all()
         finally:
             self._job_cond.release()
     if job is not None:
         self._emit(jobboard.POSTED, details={'job': job})
コード例 #6
0
 def _process_child(self, path, request):
     """Receives the result of a child data fetch request."""
     job = None
     try:
         raw_data, node_stat = request.get()
         job_data = misc.decode_json(raw_data)
         created_on = misc.millis_to_datetime(node_stat.ctime)
     except (ValueError, TypeError, KeyError):
         LOG.warn("Incorrectly formatted job data found at path: %s",
                  path, exc_info=True)
     except self._client.handler.timeout_exception:
         LOG.warn("Connection timed out fetching job data from path: %s",
                  path, exc_info=True)
     except k_exceptions.SessionExpiredError:
         LOG.warn("Session expired fetching job data from path: %s", path,
                  exc_info=True)
     except k_exceptions.NoNodeError:
         LOG.debug("No job node found at path: %s, it must have"
                   " disappeared or was removed", path)
     except k_exceptions.KazooException:
         LOG.warn("Internal error fetching job data from path: %s",
                  path, exc_info=True)
     else:
         self._job_cond.acquire()
         try:
             # Now we can offically check if someone already placed this
             # jobs information into the known job set (if it's already
             # existing then just leave it alone).
             if path not in self._known_jobs:
                 job = ZookeeperJob(job_data['name'], self,
                                    self._client, self._persistence, path,
                                    uuid=job_data['uuid'],
                                    book_data=job_data.get("book"),
                                    details=job_data.get("details", {}),
                                    created_on=created_on)
                 self._known_jobs[path] = job
                 self._job_cond.notify_all()
         finally:
             self._job_cond.release()
     if job is not None:
         self._emit(jobboard.POSTED, details={'job': job})