Пример #1
0
    def run(self):
        """
            Sets up the application, runs the command, and then tears everything down
        """
        system.initialize()

        try:
            RemoteCommand.__LOGGER.debug("Starting remote command: %s", self.__command.command_key)
            AbstractDAO.begin()
            self.__command.run()
            AbstractDAO.commit()
            RemoteCommand.__LOGGER.debug("Finished remote command: %s", self.__command.command_key)
        except Exception:
            RemoteCommand.__LOGGER.exception("Error while running remote command: %s", self.__command.command_key)
            AbstractDAO.rollback()
        finally:
            system.dispose()
Пример #2
0
import os
from rq import Worker, Queue, Connection
from synapse import system

system.initialize(os.path.abspath(os.path.join(os.path.dirname(__file__), ".env")))

if __name__ == '__main__':
    import argparse

    parser = argparse.ArgumentParser(description="Initializes a queue worker")
    parser.add_argument('queue', type=str, help="The queue you want this worker to process")
    args = parser.parse_args()

    with Connection(system.REDIS_CLIENT):
        queue = Queue(args.queue)
        worker = Worker(queue)
        worker.work()