Create sync versions of pathway to ingest messages to work around sync-only Django management commands
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
import msgpack
|
||||
from asgiref.sync import async_to_sync
|
||||
from django.core.management.base import BaseCommand
|
||||
from redis import StrictRedis
|
||||
|
||||
@@ -83,13 +82,13 @@ def process_rules(data):
|
||||
meta = {"matched": matched, "total_hits": 1}
|
||||
|
||||
# Parse the rule, we saved some work above to avoid doing this,
|
||||
# but it makes delivering messages significantly easier as we ca
|
||||
# but it makes delivering messages significantly easier as we can
|
||||
# use the same code as for scheduling.
|
||||
rule_data_object = NotificationRuleData(rule.user, rule, db=db)
|
||||
# rule_notify(rule, index, message, meta=meta)
|
||||
print("ABOUT TO RUN ASYNC TO SYNC")
|
||||
rule_matched = async_to_sync(rule_data_object.rule_matched)
|
||||
rule_matched(index, message, meta=meta, mode="ondemand")
|
||||
rule_data_object.rule_matched_sync(
|
||||
index, message, meta=meta, mode="ondemand"
|
||||
)
|
||||
|
||||
|
||||
class Command(BaseCommand):
|
||||
|
||||
Reference in New Issue
Block a user