Skip to content

Commit

Permalink
fixes id/pid usage depending on usecase
Browse files Browse the repository at this point in the history
  • Loading branch information
Roman Konoval committed Nov 28, 2024
1 parent f5e5289 commit f4d990b
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions pgpubsub/listen.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,8 +212,8 @@ def process(self):
).first()
)
if notification is None:
logger.info(f'Could not obtain a lock on notification '
f'{self.notification.id}\n')
logger.info(f'Could not obtain a lock on notification pid='
f'{self.notification.pid}\n')
else:
logger.info(f'Obtained lock on {notification}')
self.notification = notification
Expand All @@ -230,16 +230,17 @@ def validate(self):
def process(self):
logger.info(
f'Processing notification for {self.channel_cls.name()}')
notification_id = int(self.notification.payload)
notification = (
Notification.objects.select_for_update(
skip_locked=True).filter(
Q(id=int(self.notification.payload)) & get_extra_filter(),
Q(id=notification_id) & get_extra_filter(),
channel=self.notification.channel,
).first()
)
if notification is None:
logger.info(f'Could not obtain a lock on notification '
f'{self.notification.id}\n')
logger.info(f'Could not obtain a lock on notification id='
f'{notification_id}\n')
else:
logger.info(f'Obtained lock on {notification}')
self.notification = notification
Expand Down

0 comments on commit f4d990b

Please sign in to comment.