Skip to content
Snippets Groups Projects

Ocf120 implement eventreq 2

Open torrespel requested to merge OCF120-implement-eventreq-2 into staging
5 unresolved threads

Proposers

  • name-of-proposer-1 (institution-of-proposer-1)
  • name-of-proposer-2 (institution-of-proposer-2) ...

Description

Describe your proposal in ~1000 characters. You can reference external content listed in section "References" as [Ref-1].

Demo or definition of done

Describe which high level conditions needs to be fulfilled to demonstrate this feature implementation is completed. You can reference external content (example, demo paper) listed in section "References" as [Ref-2].

References

  1. Reference name
  2. Author1, Author2, Author3, et. al., “My demo using feature,” in Conference-Name Demo Track, 20XX.

Acknowledgements

This work is funded by the European Commission through the project with Grant Agreement number . example HORIZON-JU-SNS-2022 FLEX-SCALE project with Grant Agreement number 101096909.

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
66 else:
67 current_app.logger.error("monDur is in the past")
68 return bad_request_error(
69 detail="Bad Param",
70 cause="monDur is in the past",
71 invalid_params=[{"param": "monDur", "reason": "monDur is in the past"}]
72 )
73
74 if event_subscription.event_req.notif_method == "PERIODIC" and event_subscription.event_req.rep_period is None:
75 current_app.logger.error("Periodic notification method selected but repPeriod not provided")
76 return bad_request_error(
77 detail="Bad Param",
78 cause="Periodic notification method selected but repPeriod not provided",
79 invalid_params=[{"param": "repPeriod", "reason": "Periodic notification method selected but repPeriod not provided"}]
80 )
81 return expired_at
  • torrespel added 1 commit

    added 1 commit

    Compare with previous version

  • torrespel added 1 commit

    added 1 commit

    Compare with previous version

  • 1 celery==5.4
    2 pymongo==4.2.0
    3 redis==4.5.4
    4 aiohttp == 3.10.5
    5 async-timeout == 4.0.3
    6 pyyaml == 6.0.2
    7 python_dateutil >= 2.6.0
  • 1 # celery/tasks.py
    2 from celery import Celery
    3 from datetime import datetime, timezone
    4 import pymongo
    5 import os
    6 from bson.codec_options import CodecOptions
    7 from config import Config
    8 import aiohttp
    9 import asyncio
    10
    11 # Celery Configuration
    12 # celery = Celery(
    13 # "notifications",
    14 # broker=os.environ.get("CELERY_BROKER_URL", "redis://redis:6379/0"),
    15 # backend=os.environ.get("CELERY_RESULT_BACKEND", "redis://redis:6379/0")
    16 # )
  • 96 async with session.post(url, json=data, timeout=timeout, headers=headers) as response:
    97 return await response.text()
    98
    99 async def send(url, data):
    100 try:
    101 response = await send_request(url, data)
    102 print(response)
    103 except asyncio.TimeoutError:
    104 print("Timeout: Request timeout")
    105 except Exception as e:
    106 print("An exception occurred sending notification::" + str(e))
    107 return False
    108
    109 @celery.task(name="celery.tasks.check_notifications_collection")
    110 def my_periodic_task():
    111 # print("Checking notifications collection...")
  • 114 notification_data = notifications_col.find_one_and_delete(
    115 {"next_report_time": {"$lt": datetime.now(timezone.utc)}}
    116 )
    117 if not notification_data:
    118 break
    119 except pymongo.errors.AutoReconnect:
    120 print("MongoDB connection failed. Retrying...")
    121 continue
    122
    123 try:
    124 print(f"sending notification to {notification_data['url']}")
    125 asyncio.run(send(notification_data["url"], notification_data["notification"]))
    126 except Exception as e:
    127 print(f"Error sending notification: {e}")
    128
    129 # print("Finished processing notifications.")
    Please register or sign in to reply
    Loading