double calls removal
This commit is contained in:
parent
6740548171
commit
5288f6ba1b
|
@ -1,34 +1,4 @@
|
|||
from django.apps import AppConfig
|
||||
import boto3
|
||||
from django.db.models.signals import post_migrate
|
||||
|
||||
session = boto3.Session(
|
||||
aws_access_key_id='AKIAQVLBBGCB45RMLKVW', # replace with your key
|
||||
aws_secret_access_key='ZWc6KOc5LuBLuCEBDDfQTor+Q7rp3fFH74gVt+AA', # replace with your key
|
||||
)
|
||||
sqs = session.resource('sqs', region_name='ap-south-1')
|
||||
|
||||
|
||||
class ConversionConfig(AppConfig):
|
||||
name = 'conversion'
|
||||
|
||||
|
||||
def ready(self):
|
||||
post_migrate.connect(self.on_post_migrate, sender=self)
|
||||
|
||||
def on_post_migrate(self, **kwargs):
|
||||
from mnfapp.models import ScriptTranslations
|
||||
logger.info("Started Executin this from conversion")
|
||||
queue = sqs.get_queue_by_name(QueueName="mnfqueue")
|
||||
try:
|
||||
messages = queue.receive_messages(
|
||||
MessageAttributeNames=["All"],
|
||||
MaxNumberOfMessages=5,
|
||||
WaitTimeSeconds=30,
|
||||
)
|
||||
for msg in messages:
|
||||
logger.info("Received message: %s: %s", msg.message_id, msg.body)
|
||||
|
||||
except ClientError as error:
|
||||
logger.exception("Couldn't receive messages from queue: %s", queue)
|
||||
raise error
|
Loading…
Reference in New Issue