Merge pull request #106 from Teqniksoft/converter-fix

update converter
This commit is contained in:
gregory-p
2020-08-20 16:49:48 +03:00
committed by GitHub

View File

@@ -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})