def worker_cleanup(self, user_id, worker_id):
     """
     Deletes the worker and all associated data from the database as well
     as the socket directory.
     """
     with self._engine.begin() as conn:
         socket_rows = conn.execute(cl_worker_socket.select().where(
             and_(
                 cl_worker_socket.c.user_id == user_id,
                 cl_worker_socket.c.worker_id == worker_id,
             ))).fetchall()
         for socket_row in socket_rows:
             self._cleanup_socket(socket_row.socket_id)
         conn.execute(cl_worker_socket.delete().where(
             and_(
                 cl_worker_socket.c.user_id == user_id,
                 cl_worker_socket.c.worker_id == worker_id,
             )))
         conn.execute(cl_worker_run.delete().where(
             and_(cl_worker_run.c.user_id == user_id,
                  cl_worker_run.c.worker_id == worker_id)))
         conn.execute(cl_worker_dependency.delete().where(
             and_(
                 cl_worker_dependency.c.user_id == user_id,
                 cl_worker_dependency.c.worker_id == worker_id,
             )))
         conn.execute(cl_worker.delete().where(
             and_(cl_worker.c.user_id == user_id,
                  cl_worker.c.worker_id == worker_id)))
Esempio n. 2
0
 def worker_cleanup(self, user_id, worker_id):
     """
     Deletes the worker and all associated data from the database as well
     as the socket directory.
     """
     with self._engine.begin() as conn:
         socket_rows = conn.execute(
             cl_worker_socket.select()
                 .where(and_(cl_worker_socket.c.user_id == user_id,
                             cl_worker_socket.c.worker_id == worker_id))
         ).fetchall()
         for socket_row in socket_rows:
             self._cleanup_socket(socket_row.socket_id)
         conn.execute(cl_worker_socket.delete()
                      .where(and_(cl_worker_socket.c.user_id == user_id,
                                  cl_worker_socket.c.worker_id == worker_id)))   
         conn.execute(cl_worker_run.delete()
                      .where(and_(cl_worker_run.c.user_id == user_id,
                                  cl_worker_run.c.worker_id == worker_id)))      
         conn.execute(cl_worker_dependency.delete()
                      .where(and_(cl_worker_dependency.c.user_id == user_id,
                                  cl_worker_dependency.c.worker_id == worker_id)))      
         conn.execute(cl_worker.delete()
                      .where(and_(cl_worker.c.user_id == user_id,
                                  cl_worker.c.worker_id == worker_id)))