feat: Improve processing speed by increase Rabbit fetch count

This commit is contained in:
2021-02-26 18:17:33 +03:00
parent f40fa73c39
commit eb20e30d44
2 changed files with 7 additions and 4 deletions

View File

@@ -13,6 +13,7 @@ from src.messages import AnalyzeResponse
BATCH_SIZE = 100
RABBIT_CONSUME_TIMEOUT = 4
PREFETCH_COUNT = 20 # only one consumer and quick processing -> can be big
def get_user_id(session, name: str):
@@ -114,11 +115,11 @@ def process_task_replies(session, channel, consume_count: int):
def main():
consume_count = 0 if len(sys.argv) == 1 else int(sys.argv[1])
session = DBSession()
channel = get_channel()
channel = get_channel(prefetch_count=PREFETCH_COUNT)
try:
process_repositories(session=session, channel=channel, consume_count=consume_count)
channel.close()
channel = get_channel()
channel = get_channel(prefetch_count=PREFETCH_COUNT)
process_task_replies(session=session, channel=channel, consume_count=consume_count)
finally:
session.commit()