Coverage for portality / events / background.py: 100%

7 statements  

« prev     ^ index     » next       coverage.py v7.13.5, created at 2026-05-05 00:09 +0100

1from portality.core import app 

2from portality.tasks.process_event import ProcessEventBackgroundTask 

3 

4 

5def send_event(event): 

6 """ 

7 Send an event to be processed asynchronously by creating and submitting a background job. 

8 Returns the background job id for convenience (e.g., to show in UI). 

9  

10 :param event: The event to be processed 

11 :return: the id of the enqueued background job 

12 """ 

13 # Get the system username for creating the background job 

14 username = app.config.get("SYSTEM_USERNAME") 

15 

16 # Create and submit a background job for processing the event 

17 job = ProcessEventBackgroundTask.prepare(username, event=event) 

18 ProcessEventBackgroundTask.submit(job) 

19 return job.id