forked from LiveCarta/BookConverter
@@ -41,7 +41,7 @@ def convert_book(book_id, access, logger, libra_locker):
|
||||
raise exc
|
||||
|
||||
logger.info(f'Book-{book_id} has been proceeded.')
|
||||
# print('Book has been proceeded.')
|
||||
print('Book has been proceeded.')
|
||||
|
||||
|
||||
def callback(ch, method, properties, body, logger, libra_locker):
|
||||
@@ -67,12 +67,10 @@ def callback(ch, method, properties, body, logger, libra_locker):
|
||||
if hasattr(exc, 'message'):
|
||||
logger.error(f'{sys.exc_info()[0]}: {exc.message}')
|
||||
else:
|
||||
logger.error(f'{sys.exc_info()[0]}')
|
||||
logger.error(f'{sys.exc_info()[0]}: {str(exc)}')
|
||||
|
||||
finally:
|
||||
pass
|
||||
# thread.join()
|
||||
# print('Waiting for the message...')
|
||||
|
||||
|
||||
def local_convert_book(filename, locker):
|
||||
@@ -107,21 +105,24 @@ def local_run(books):
|
||||
|
||||
|
||||
def server_run():
|
||||
logger = configure_file_logger('consumer', logging_format='%(asctime)s - %(levelname)s - %(message)s')
|
||||
|
||||
folder_path = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||
# config_path = Path(os.path.join(folder_path, "config/config.json"))
|
||||
config_path = Path(os.path.join(folder_path, "config/queue_config.json"))
|
||||
with open(config_path, "r") as f:
|
||||
conf_param = json.load(f)
|
||||
|
||||
host = conf_param.get('host') or pika.ConnectionParameters().DEFAULT_HOST
|
||||
port = conf_param.get('port') or pika.ConnectionParameters().DEFAULT_PORT
|
||||
|
||||
credentials = pika.PlainCredentials(username=conf_param['username'], password=conf_param['password'])
|
||||
parameters = pika.ConnectionParameters(host=host, port=port, credentials=credentials)
|
||||
connection = pika.BlockingConnection(parameters)
|
||||
channel = connection.channel()
|
||||
|
||||
logger = configure_file_logger('consumer', logging_format='%(asctime)s - %(levelname)s - %(message)s')
|
||||
channel = None
|
||||
try:
|
||||
credentials = pika.PlainCredentials(username=conf_param['username'], password=conf_param['password'])
|
||||
parameters = pika.ConnectionParameters(host=host, port=port, credentials=credentials)
|
||||
connection = pika.BlockingConnection(parameters)
|
||||
channel = connection.channel()
|
||||
except Exception as exc:
|
||||
logger.log(logging.ERROR, f'Problems with queue connection.\n' + str(exc))
|
||||
raise exc
|
||||
|
||||
try:
|
||||
channel.queue_declare(queue=conf_param['queue'], durable=True, arguments={'x-max-priority': 10})
|
||||
|
||||
Reference in New Issue
Block a user