Skip to content

Commit

Permalink
Async to sync
Browse files Browse the repository at this point in the history
  • Loading branch information
KoalaSat committed Aug 7, 2024
1 parent b1ebdf4 commit 06822c0
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions api/tasks.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import asyncio
from asgiref.sync import async_to_sync
from celery import shared_task
from celery.exceptions import SoftTimeLimitExceeded

Expand Down Expand Up @@ -261,7 +261,7 @@ def nostr_send_order_event(order_id=None):
order = Order.objects.get(id=order_id)

nostr = Nostr()
asyncio.run(nostr.send_order_event(order))
async_to_sync(nostr.send_order_event)(order)

return

Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,4 @@ django-cors-headers==4.4.0
base91==1.0.1
nostr-sdk==0.32.2
pygeohash==1.2.0
asgiref == 3.8.1
3 changes: 1 addition & 2 deletions tests/utils/trade.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from api.management.commands.clean_orders import Command as CleanOrders
from api.management.commands.follow_invoices import Command as FollowInvoices
from api.models import Order
from api.tasks import follow_send_payment, send_notification, nostr_send_order_event
from api.tasks import follow_send_payment, send_notification
from tests.utils.node import (
add_invoice,
create_address,
Expand Down Expand Up @@ -156,7 +156,6 @@ def process_payouts(self, mine_a_block=False):
wait_nodes_sync()

@patch("api.tasks.send_notification.delay", send_notification)
@patch("api.tasks.nostr_send_order_event.delay", nostr_send_order_event)
def publish_order(self):
# Maker's first order fetch. Should trigger maker bond hold invoice generation.
self.get_order()
Expand Down

0 comments on commit 06822c0

Please sign in to comment.