code: def push_intercom_event_task(obj_id):
      
      lock_id = "%s-push-intercom_event-%s" % (settings.ENV_PREFIX, obj_id)
      acquire_lock = lambda: cache.add(lock_id, "true", LOCK_EXPIRE)  # noqa: E731
      release_lock = lambda: cache.delete(lock_id)  # noqa: E731
  
      if acquire_lock():
          from aa_intercom.models import IntercomEvent
          try:
              instance = IntercomEvent.objects.get(pk=obj_id)
              if instance.is_sent:
                  return
  
              data = instance.get_intercom_data()
              try:
                  if instance.user:
                      upload_intercom_user(instance.user.pk)
                  else:
                      upload_not_registered_user_data({"email": data["metadata"]["email"]})
                  if not getattr(settings, "SKIP_INTERCOM", False):
                      intercom.events.create(**data)
                      IntercomEvent.objects.filter(pk=obj_id).update(
                          is_sent=True
                      )
              except IntercomError:
                  IntercomEvent.objects.filter(pk=obj_id).update(
                      is_sent=False
                  )
                  release_lock()
                  raise  # FIXME - to check when errror happens
  
          except IntercomEvent.DoesNotExist:
              release_lock()
              raise
          release_lock()
docs: Async: push_intercom_event_task.delay(event.id)